This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

SelectOneRadio from a Stringtype List. No Selection possible

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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: 21129
131
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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: 21129
131
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
I do some of my very best work in water. Like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!