• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF Facelets ui:param

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

look at that:




The only problem is: The variable 'key' is declared AFTER the selectOneRadio, so it is out of range..

I cannot assign a String-Concat to a map like this:

<h:selectOneRadio value="#{myBean.mySelectedKeys[#{listA.name}/#{listB.name}]}">
.

Is there a better way to get the selected value in my Map???
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, don't treat the View as though it was a program. That is, remove the (JSTL) logic. JSF views are supposed to be 2-dimensional maps, not linear constructs. Besides, JSTL and JSF don't play all that well together - they're really designed for 2 different concepts.

Normally, you'd use a JSF datatable for a variable-size multi-row display. JSF pages are not expected to have loops or conditionals (other than conditional rendering).

Next up, the value attribute on a button group is a read-write expression, so you can't do the equivalent of 'value="#{2+2}"' since there's no place to write the button selection back to.

Returning to the concept that a JSF View is more of a true MVC view than what you have with straight JSP, JSP+JSTL or Struts, the preferred place to do calculations is in the model, not on the view itself. Simple EL variable references are preferable to computations for most purposes.

Finally, for anything resembling XML - including JSF and even JSP tags, you can't count on attributes being processed in the order you code them on the page, so you shouldn't code dependencies or side-effects based on what physical relationship they have in the file. Effectively, what is more likely to happen is that the page parser will see the tag, collect all the attributes into a dictionary (HashMap, for example), then pass the whole thing as a unit to the tag handler. Dictionaries don't know what order the elements were added in.
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay..but this helps me not out.

I cannot not use binding for all the generated (!) Items, the count of selectItems depends on the items having in the database..so I have to do it dynamically. Should I use binding?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!