On Fri, 2007-09-28 at 08:40 -0700, Gianluca Correndo wrote:
> Hello everyone,
> I have started to develop with MyFaces and Tobago few weeks ago. I
> have used
> tomahawk for a while and with it there was an easy way to add
> parameters to an
> event for customising actions. For example in a page I could add a link
> to
> erase one ontology I manage:
>
> <t:commandLink styleClass="submitButton" value="erase" id="eraseC"
> action="#{SessionBean.eraseOntology}">
> <f:param name="oid" value="#{ontology.id}"/>
> </t:commandLink>
>
>
> And the event handler was able to retrieve the parameter "oid" from the
> faces
> context with:
>
> public void eraseOntology(ActionEvent actionEvent){
> String oid =
> javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("oid");
>
> Now in the Tobago library this doesn't work anymore. How can I
> achieve the
> same behaviour?
I don't know why it's not working, but there is an elegant alternative.
With JSF1.1 you can use the tomahawk t:updateActionListener tag to get
the same effect. The JSF1.2 standard has made this a part of the
standard.
For JSF1.1, see updateActionListener here:
http://myfaces.apache.org/tomahawk/tlddoc/index.html
<t:commandLink ....>
<t:updateActionListener
property="#{SessionBean.ontologyToErase}"
value="#{ontology.id}"/>
</t:commandLink>
The setOntologyToErase method will be called before eraseOntology.
For JSF1.2, see f:setPropertyActionListener here:
http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/index.html
NB: I haven't used this for a while so the syntax might not be exactly
right..
Regards,
Simon