But the link won't be correct what I want. If #{bean.method} returns
"test.xhtml" the anchor will be
<a id="_id0" href="test.xhtml?nameOfVariable=valueOfVariable"/>
The url needs to be exactly what I have below. It's for a sites
navigation so for search engine optimization (SEO) reasons I can't be
having it do any "funny" things. It must be
href="c/b/a.xhtml"
Am I doing something wrong? Any other ideas?
Thanks,
David
Schaal, Roland wrote:
Have a look at <f:param> to pass an attribute to a method.
For Example:
<h:outputLink value="#{bean.method}">
<f:param name="nameOfVariable" value="valueOfVariable" />
</h:outputLink>
-----Ursprüngliche Nachricht-----
Von: David Schlotfeldt [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 5. April 2006 04:56
An: [email protected]
Betreff: is it possible to call a method and pass an arguement from jsf?
I have a backing bean called Menu that has a method getMenuItems() that returns
a List of MenuItems. Each MenuItem has an id, title, and child MenuItems which
are in a List.
I want the url of menu items to be a join of the menuitem's id and its
ancestors' id.
Eg. if we are on 'a' and its parent is 'b' and its parent is 'c' then i want
the url to be c/b/a.xhtml
What is the best way to go about doing this?
The only thing I can think of doing is adding a method on to MenuItem called getURL(). That would work but I would rather not do that simply .
Anyone have another solution?
I want to do something like.... #{menu.createURL(currentMenuItem)}
but as far as I know you can't call methods with arguments.
Thanks,
David
(Just to note, I have no problem with adding getParent() on to menu items even
though I don't have it right now.)