You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Gianluca Correndo <gi...@yahoo.com> on 2007/09/28 17:40:45 UTC
adding parameters for actionHandler
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?
Thanks in advance
Gianluca
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/
Re: adding parameters for actionHandler
Posted by Gianluca Correndo <gi...@yahoo.com>.
Hi Simon,
thanks for the help. I don't know why Trinidad 'param' didn't work. I've
setted up the environment for Tobago, maybe I lost some filter on the way..
In any case, I've been able to fix the problem using this:
JSF:
<tc:button label="erase" actionListener="#{OntologyManager.eraseOntology}">
<f:param name="toErase" value="#{ontology}" />
</tc:button>
--- simon <si...@chello.at> wrote:
> 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
>
>
____________________________________________________________________________________
Catch up on fall's hot new shows on Yahoo! TV. Watch previews, get listings, and more!
http://tv.yahoo.com/collections/3658
Re: adding parameters for actionHandler
Posted by Gianluca Correndo <gi...@yahoo.com>.
Hi Simon,
thanks for the help. I don't know why Trinidad 'param' didn't work. I've
setted up the environment for Tobago, maybe I lost some filter on the way..
In any case, I've been able to fix the problem using this:
JSF:
<tc:button label="erase" actionListener="#{OntologyManager.eraseOntology}">
<f:param name="toErase" value="#{ontology}" />
</tc:button>
Java:
UICommand link = (UICommand)actionEvent.getComponent();
UIParameter param = (UIParameter)link.getChildren().get(0);
Ontology toErase = (Ontology) param.getValue();
Thanks for letting me know about the updateActionListener, I think I'll use
it for other parts of the application.
Thanks again.
Gianluca
--- simon <si...@chello.at> wrote:
> 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
>
>
____________________________________________________________________________________
Catch up on fall's hot new shows on Yahoo! TV. Watch previews, get listings, and more!
http://tv.yahoo.com/collections/3658
Re: adding parameters for actionHandler
Posted by simon <si...@chello.at>.
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