Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Value status of check box in java

 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am using JSF and as per my work requirement I have to check whether a check box is selected or not in java class because all my processing is dependent on whether or not check box is selected.

can anyone tell me how value of check box (selected or deselected) is available in java class.(the java class i am talking about is not a managed bean)



 
Davie Lin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you can look into javax.faces.component.html.HtmlSelectBooleanCheckbox

 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tanu,

Can you explain more clearly where you want the value statue of checkbox (I mean which java class other than managed bean)
 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain more clearly where you want the value statue of checkbox (I mean which java class other than managed bean)


requirement says that i have to enable/disable some radio buttons depending on whether the check box is selected/deselected.


 
Vinodh Sa
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tanu,
May be you can try this.

While creating your check box, use the value attribute for it and associate it with a (boolean) variable of your java code. (And declare that variable in your java code, try using boolean datatype).
EX: <h:selectBooleanCheckbox id="checkBoxID" value="#{beanName.variableName}" />
And also declare the getters and setters for that variable in your java code.
Then try using the following kind of code:
if(isVariableName()) //means that the check box is checked
{
//your logic comes here for enabling/disabling that radio button. May be you can try using a similar kind of logic(associating a boolean variable with your radio button also, and set that variable to true in this part of code and false in the else part)
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic