-
1. Re: Page Parameters Question Take 2
yahawari Dec 23, 2009 1:13 AM (in response to jpalmer1026.jpalmer1026.mchsi.com)basically page parameters should contain basic types (or their wrappers). for anything other than the basic types u will need to write a converter. for example Date is an object, seam has a date JSF converter that will allow u to pass it as a page param.
however for ur scenario, it is easier to just pass the id of the object then fetch it on form submit.
-
2. Re: Page Parameters Question Take 2
jpalmer1026.jpalmer1026.mchsi.com Dec 23, 2009 3:58 PM (in response to jpalmer1026.jpalmer1026.mchsi.com)Thanks for the explanation. Maybe I misunderstood your explanation but I ended up changing my code like so:
<s:decorate template="layout/display.xhtml"> <ui:define name="label">Bureau</ui:define> <h:selectOneMenu id="bureau" value="#{employeeExample.bureau.id}"> <s:selectItems var="_bureau" value="#{bureaus}" label="#{_bureau.name}" noSelectionLabel="-- Select --" /> <s:convertEntity /> <a:support event="onchange" /> </h:selectOneMenu> </s:decorate>
<param name="bureau" value="#{employeeExample.bureau.id}"/>
These changes are resulting in the following error message:
08:51:36,009 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed. sourceId=employeeSearch:j_id39:bureau[severity=(ERROR 2), summary=(/EmployeeList.xhtml @37,73 value="#{employeeExample.bureau.id}": Target Unreachable, 'bureau' returned null on 'org.cityofchicago.water.dma.entity.Employee'), detail=(/EmployeeList.xhtml @37,73 value="#{employeeExample.bureau.id}": Target Unreachable, 'bureau' returned null on 'org.cityofchicago.water.dma.entity.Employee')]
Am I doing something blatantly wrong?
-
3. Re: Page Parameters Question Take 2
mikkus70 Dec 23, 2009 4:57 PM (in response to jpalmer1026.jpalmer1026.mchsi.com)Your form is using <s:convertEntity>, but your backing property seems to be an ID (possibly a Long). The purpose of <s:convertEntity> is that of passing an entity
directly
, so that your backing property should be an instance of the entity class (so, instead of #{employeeExample.bureau.id}, you would probably want to use #{employeeEXample.bureau}).The other thing is that page parameters use converters much like form fields do...
I've personally grown to dislike entity conversion, at least for simple use cases like these. I find using the entity id as key for the combo is not complicated and makes the code more understandable, so I would just add an itemValue property to the <s:selectItems> tag and remove the <s:convertEntity>. This of course means that you need to load the entity when submitting back the form, but for search screens it is usually sufficient to just filter by the id.
Finally, as said by Yasser, your scenario is probably simple enough to just leave the combo within the same form as the
order by
action and its contents will be automatically submitted back to the server when ordering the results. -
4. Re: Page Parameters Question Take 2
jpalmer1026.jpalmer1026.mchsi.com Dec 23, 2009 5:08 PM (in response to jpalmer1026.jpalmer1026.mchsi.com)Thanks for the prompt response, Emir. If you look at my first post in this thread, you'll notice that I am in fact using
#{employee.bureau}
as my backing property. The question then becomes how can I use employee.bureau in my page.xml class without it breaking the code? I'm presuming I need a converter for this, so if someone could let me know what that should look like, that would be very helpful.