File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how use a <li>with <h:commandLink> ?" Watch "how use a <li>with <h:commandLink> ?" New topic
Author

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

Hector Usma
Greenhorn

Joined: Oct 28, 2011
Posts: 1
Hi

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>



PeriodicoBean.java 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...

thnaks



[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.

Regards,
Brendan.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how use a <li>with <h:commandLink> ?
 
Similar Threads
Issue with my webApp
json object send to JSF backing bean to xhtml page
Can't get to the bean methods
Show hide component using Ajax
set values in a table from other