File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Checkbox on show div tag when the page is loaded Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Checkbox on show div tag when the page is loaded" Watch "Checkbox on show div tag when the page is loaded" New topic

Checkbox on show div tag when the page is loaded

Jayasri Alaparthi
Ranch Hand

Joined: Aug 14, 2006
Posts: 67
Hi Friends,

I have a check box and the information of if it is checked or not, comes from Actionform get, I want the div tag to be displayed when the jsp is first loaded and the check box is checked, and the inforamtion of it I get from Action-dao-bean.

I am using logic:iterator and getting the value and property form bean

Can some one help me in sending the sample code for this.

with regards,
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

Lets say you have a form bean with this getters and setters,

in JSP,

It is checking for the property 'symbol' in bean, if it is 'Y' then 'checked' attribute is included in the checkbox control. If it is other than 'Y', then it is not checked.

Hope it helps.

- Marimuthu Madasamy
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
It sounds like you have a situation where if a checkbox is checked then you need to show some additional fields and when the checkbox is cleared you need to hide some additional fields. Is this correct? Do you already have JavaScript code in place to do this at runtime?

To set the state when the page if first shown you can do one of two things. You could use scriptlet code or custom tags in your JSP to create the fields you need in the desired state. The other option is to call your JavaScript function when the page loads. The benefit of using JavaScript is that you don't have to implement the logic twice.

- Brent
I agree. Here's the link:
subject: Checkbox on show div tag when the page is loaded
It's not a secret anymore!