I have a set of categories and I want to display that as hyperlinks in my JSF page.
If the user clicks in one of them, the category ID is submitted and the action BookController.filterByCategory is called.
This is my code:
And when I browse the page, apparently it doesn't work:
The setValue in bookBean should have at least one property to store a value for each of the array elements you are iterating over.
If your list does not require to change for al the categories you can set each property value into
and Array or java.util.List and assign in faces-config.xml managed properties for the managed bean.
for now or till someone else sees this thread and shows you: See the J2EE tutorial "Managed Beans" (Backing Beans) at the http://www.java.sun.com site.
Just got back, i had some time to think.
Firstly, your using a scriptlet to attempt to "evaluate" a scriptlet call.
Secondly , you don't need to use the value attribute "with a tag that has a binding= to a producer method of the java type its producing.
The errors refer to :
type int getId and
You should have set the value in the component producer method programmatically.
JSP and JSTL use a writing evaluater to the output stream when evaluating the JSP page called A JspWriter.
JSF uses between JSP and JSF in synchronicity (for evaluating the page) a (JSF Writer) ResponseWriter.
E.G. (methods) void encodeBegin , void encodeEnd and decode for retrieval with a Renderkit
Here's the tricky bit.
When a JSP/JSTL tag or scriptlet is seen in the markup, the JspWriter evaluates them, but if a JSF tag is seen , the JSP evaluator is switched to wait().
But if you write a JSF custom tag, it is picked up by the JSP writerand can/will evaluate scriptlet in its attributesbecuase the
tag registration in the page markup is JSP and it hasn't started to be operated on until the page information is inside the tags class binaries. Inside the tag class code to make a JSF custom tag, a call to the JSF instance and JSF writer(the ResponseWriter object) is made to operate and encode()
methods are used to produce the output component before writing it to out.
If anything (i haven't specifically checked its as simple as this) you could import the FacesContext at the top of your page and because the managed bean declaration
name is the same as using the jsp:useBean id= reference you could do ... example-ish but that requires climbing into the map of the application bean introspection indexer classes:
="<%= categoryBeanName.get(i).getName() %>"