• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SelectOneRadio from a Stringtype List. No Selection possible

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i am struggling with the problem that my radio buttons, wich are dynamically created are intially checked.

JSF:



The ouptut on the application is right. Problems are:

- All radio buttons are checked initally
- No further selection is possible

I would appreciate any help. Thank you guys !
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What? "Controller" and not "Kontroller"? But JSF backing beans are not Controllers. They are Models.

As a general rule, I discourage the use of ui:repeat and other logic-like constructs. If you have a tabular display, use the dataTable tag, instead. However, ui:repeat does have uses, such as when you want to arrange your collection horizontally rather than vertically.

There are several basic items that need to be addressed.

1. f:selectItem needs both an itemLabel and and itemValue. The itemValue is the value that will be posted to the radio control's target.

2. You must name a target in the h:selectOneRadio that will receive the selected value - and conversely be used to set the displayed selection. This is the "value=" attribute of the selectOneRadio tag element.

3. Normally when you nest iterative and tabular constructs, the inner construct's "value" attribute references the outer construct's "var" value.

I think before doing anything this ambitious, you need to study up on a few basics of JSF.

 
Tuenay Oezcan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim! Thanks for the reply. Yes my bean class is called controller, since my model class is a entity class which holds everything from my database. Can you please post an example of how to use select one radio buttons in a data table. Its just weird because my lists are correctly executed. The only problem is to save the selected value in a arrayList, which should be possible in a select one radio value....I changed my code to the following:



Is there any way to put an index on the <h:selectOneRadio id="radio" value="#{fragebogenController.antwortUser}" list antwortUser?

You are totally right about the basics i am actually sitting here (for 4 weeks now) with numerous jsf for dummies book but since my user requirements include such a problem i can`t seem to solve it with the basics ;)

Thank you very much!!!


 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do not mistake the UI Model for the Business or Persistence Models. JSF backing beans are UI Models. In JSF, the Controllers are pre-supplied by the framework, not coded as application functions.

You do not have an "index" for a selectOne control. Instead, the value corresponding to the SelectItem is injected into the control's "value=" property. Conversely, if the model sets this property, the next time the View is displayed, the button whose selectItem value matches will be displayed selected. A Validation exception occurs if no selectItem value can be found that matched.

It is good practice to include the "id=" attribute on all input controls. Some JSF error messages display control IDs, and the ones that are synthesized by default when no explicit ID is supplied are usually neither predictable nor helpful.
reply
    Bookmark Topic Watch Topic
  • New Topic