Apr
16
2004
Maybe I’m hitting another JSF quirk… but I have yet to see an example using this method:
Lets say I have a drop down list:
<h :selectOneMenu id="hardwareTypeItem" value="#{Model.hardwareTypeItem}">
<f :selectItems value="#{Item.hardwareTypeItems}"></f>
</h>
this is my Item.hardwareTypeItems:
List items = mgr.getAllHardwareTypeItems();
for (int i = 0; i < items.size(); i++) {
h = (HardwareTypeItem) items.get(i);
hardwareTypeItems.add(new SelectItem(h,h.getDescription(),h.getDescription()))
}
Here is my Model.hardwareTypeItem:
/**
* @return Returns the hardwareTypeItem.
* @hibernate.many-to-one column="type_id"
*/
public HardwareTypeItem getHardwareTypeItem() {
return hardwareTypeItem;
}
Being realistic, I doubt the assumption of JSF to just know hey that’s my object and update the Model with the proper reference, but that’s not the case and shoots back a “Conversion error occurred” for the message output.
— UPDATE —
After a little digging around, I downloaded the JSF source code and happened to stumble upon additional examples under the ‘’standard” directory. Now I feel a bit dumb as its straight forward process using the javax.faces.convert.Converter interface.
I created a converter and then just register your custom converter in the faces-config.xml file like so:
<converter>
<converter -for-class>model.item.BaseItem</converter>
<converter -class>converters.BaseItemConverter</converter>
</converter>
Comments Off | tags: java, jsf | posted in Tech
Apr
14
2004
I”m playing around with JSF and a *small* web app but I have noticed managed bean’s methods are getting called twice. This present a problem when trying to build a select menu drop down collection list of superset values.
This selectOne:
<h :selectOneMenu id="hardwareTypeItem" value="#{Model.hardwareTypeItem}">
<f :selectItems value="#{Item.hardwareTypeItems}"></f>
</h>
Will cause this issue when the selectItems collection is being populated.
13:13:11,828 INFO ItemForm:? - ItemForm()
13:13:12,048 INFO HibernateTransactionManager:313 - Initiating transaction commit
13:13:12,048 INFO ItemForm:? - [javax.faces.model.SelectItem@b28f30, javax.faces.model.SelectItem@d6a0e0, javax.faces.model.SelectItem@dbf04d, javax.faces.model.SelectItem@17d80e9, javax.faces.model.SelectItem@9a44d6, javax.faces.model.SelectItem@1d5ebc, javax.faces.model.SelectItem@36b1bb, javax.faces.model.SelectItem@ce88d2, javax.faces.model.SelectItem@1789a96, javax.faces.model.SelectItem@ecfaea, javax.faces.model.SelectItem@4d37e5]
13:13:12,058 INFO HibernateTransactionManager:313 - Initiating transaction commit
13:13:12,058 INFO ItemForm:? - [javax.faces.model.SelectItem@1c8c58, javax.faces.model.SelectItem@422510, javax.faces.model.SelectItem@8f5944, javax.faces.model.SelectItem@12d9844, javax.faces.model.SelectItem@67a232, javax.faces.model.SelectItem@1c98c1b, javax.faces.model.SelectItem@10d78ec, javax.faces.model.SelectItem@17df472, javax.faces.model.SelectItem@3b9a5f, javax.faces.model.SelectItem@113dd59, javax.faces.model.SelectItem@12929b2]
The only work around solution is to check if the ArrayList == null and not populate the list again. This is not an ideal solution because if another application/person is updating those drop down supersets I”ll miss out on a new updated list until the session scoped bean is destroyed.
Comments Off | tags: java, jsf | posted in Tech
Apr
2
2004
Some days I’d rather be out driving the new R32

R32 first night home
I love Spring + Hibernate…
Comments Off | tags: hibernate, R32 | posted in Cars, Tech