This content has been marked as final.
Show 5 replies
-
1. Re: Injecting <f:param> howto ?
drapierwim Oct 19, 2005 4:48 PM (in response to lcoetzee)@In(required=false, value="#{selectedServiceId}") private Long selectedServiceId;
Non primitieve datatypes won't work here simple because there is no instance created, when you change it to long you will see that an injection is done when the seam component is created, resulting in another error because seam doesn't know the selected value.
please correct me if I'm wrong. -
2. Re: Injecting <f:param> howto ?
lcoetzee Oct 20, 2005 6:44 AM (in response to lcoetzee)I have made some progress with regard to using non-primitives. Using an int brings Seam to attempt to inject a value, but throws an exception (as suggested by the previous poster).
The exception:Caused by: javax.ejb.EJBTransactionRolledbackException: null; CausedByException is: could not inject: #{selectedServiceId} to: serviceViewerAction
I have changed (simplified) my code as follows (to get the above exception):@In(value="#{selectedServiceId}", required=false) @Out (required=false) private int selectedServiceId;
with xhtml<h:commandLink action="#{serviceViewerAction.viewSelected}" id="viewSelectedID"> <h:outputText value="test" /> <f:param id="selectedServiceId" name="selectedServiceId" value="171" /> </h:commandLink>
Still learning (slowly unfortunately ;-).
L -
3. Re: Injecting <f:param> howto ?
gavin.king Oct 26, 2005 6:54 AM (in response to lcoetzee)The CVS build of Seam supports use of JSF expressions in @In. However, the only way to get the value of an <f:param> is to go direct to the FacesContext.
-
4. Re: Injecting <f:param> howto ?
lcoetzee Oct 26, 2005 7:42 AM (in response to lcoetzee)Thanks for the confirmation.
In the end I did the following:FacesContext context = FacesContext.getCurrentInstance(); Map map = context.getExternalContext().getRequestParameterMap(); String serviceNr = (String) map.get("selectedServiceId"); if (serviceNr.length() > 0) { logger.info("Retrieved: " + serviceNr + "from <f:param ... "); selectedServiceNr = new Integer(serviceNr); }
Regards
Louis -
5. Re: Injecting <f:param> howto ?
gavin.king Oct 26, 2005 11:19 AM (in response to lcoetzee)Right, this is one way.
You can even inject the FacesContext, if you like.