Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Hector Usma
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18661
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!