File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes how use a <li>with <h:commandLink> ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how use a <li>with <h:commandLink> ?" Watch "how use a <li>with <h:commandLink> ?" New topic

how use a <li>with <h:commandLink> ?

Hector Usma

Joined: Oct 28, 2011
Posts: 1

I from Colombia and my english isn't perfect, but try to be clear.

I have a problem, need to do a menu bar with some items, I'm using <li>.. then when somebody click on the item o element from menu, catch the event and sent it to a Bean made in Java... this is my code.. an some picture of the page, I'm only coding the firts list <li>, also isn't apper the name that I'm assingin to the <li> is the name of the bean, it has 2 methods setEvento, getEvento y share de bean code

this is the image of the page

please help me , I'm very confused nothing works me...


[Thumbnail for ing.jpg]

Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218
Hi, the way you're using li looks ok to me, but here are some suggestions:

1. Move f:view to before <head>. It's better to use f:view contentType="text/html" - this keeps webkit browsers
like chrome happy.

2. Change <head> to <h:head>, and <body> to <h:body>. Although this may not affect your specific code, it
can be important and is a good idea to get into the habit of specifying the header and body like this.

3. What's likely to be the biggest problem is that you are not specifying an action method correctly, you have:
action="#{periodicoBean} where I would expect you to have something like action="#{periodicoBean.someMethod},
where you have public String someMethod() in periodicoBean.

4. You don't specify a bean scope (i.e. @RequestScoped). I can't remember if request scope if the default or
@NoneScoped is?

5. You are using setPropertyActionListener to set periodicoBean.evento to "per" (the id of the commandLink). This
will simply set evento to the string value "per", which may not be what you want.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

Actually, I discourage use of raw HTML in JSF webapps entirely.

For the specific case of the <li> tag, CSS afficionados actually prefer CSS over the traditional list item tag anyway. JSF relies heavily on CSS.

More specifically, however, I'd really recommend looking at some of the extension tagsets such as Apache Tomahawk, RichFaces, PrimeFaces, IceFaces, and so forth. Many of those tagsets include tags specifically designated to construct menus using JSF.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: how use a <li>with <h:commandLink> ?
It's not a secret anymore!