Friday, November 27, 2015

Associate a map property to user input field using converter

How to associate a map property to user input field while using formhandler?

HTML forms can set values to formhandler components using bean attribute of dsp:input tags. However if you want to associate user input values to a map attribute it can be done as follows,

<dsp:input bean="FormHandler.map-property" converter="map"  value="key=value" />

Suppose I have a map called primaryAddress in a custom formhandler MyFromHandler and addressLine1, addressLine2, city, state are attributes that needs to be captured from user. In this case we can set 4 input fields and can associated to map attributes directly.

<dsp:input bean="MyFromHandler.primaryAddress" converter="map" value="addressLine1=" />
<dsp:input bean="MyFromHandler.primaryAddress" converter="map" value="addressLine2=" />
<dsp:input bean="MyFromHandler.primaryAddress" converter="map" value="city=" />
<dsp:input bean="MyFromHandler.primaryAddress" converter="map" value="state=" />

Map property association can be done for multiple values loaded for a hidden variable as well.

<dsp:input bean="MyFromHandler.primaryAddress" converter="map" type="hidden" value="addressLine1=${loadedAddress.addressLine1}, addressLine2=${loadedAddress.addressLine2}, city=${loadedAddress.city}, state=${loadedAddress.state}">
</dsp:input> 


Wednesday, November 18, 2015

Weak Cache Hashtable

Weak cache hash table stores the items that have been removed from the cache, that have not yet been run through the garbage collection process. Entries in this table have been tagged as weak, indicating that they will be passed through the garbage collection process as soon as no further references are found for them. All items will be having weak references.

Scenario 

If the system maintains a reference to an item that has been removed from the cache, it would continue to used the item. When a new item with the same ID is created later, the repository can no longer synchronize all of the changes made. To prevent this, whenever an item is removed from the cache, it is added to a weak reference Hashtable. When an item is not found in the cache, the repository references this Hashtable. If the item it found, it is added back to the cache.