File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Value status of check box in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Value status of check box in java" Watch "Value status of check box in java" New topic
Author

Value status of check box in java

Tanu Gulati
Ranch Hand

Joined: Oct 06, 2008
Posts: 113

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)




thanks
Tanu Gulati
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
Maybe you can look into javax.faces.component.html.HtmlSelectBooleanCheckbox

suresh dasari
Ranch Hand

Joined: Oct 05, 2009
Posts: 121

Tanu,

Can you explain more clearly where you want the value statue of checkbox (I mean which java class other than managed bean)


Sun Certified Java Programmer with 93 percent
Tanu Gulati
Ranch Hand

Joined: Oct 06, 2008
Posts: 113

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

Joined: May 06, 2010
Posts: 55
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)
}

Thanks, Vinodh
[Servlet tutorial]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Value status of check box in java