aspose file tools*
The moose likes Struts and the fly likes How to make checkbox checked in display tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to make checkbox checked in display tag" Watch "How to make checkbox checked in display tag" New topic
Author

How to make checkbox checked in display tag

Raaja Gotluru
Ranch Hand

Joined: Mar 02, 2010
Posts: 107
Hi,

I am using struts framework and in the jsp I am having display table like below.


<display:table id="data" name="deptUsers" requestURI="/getUsersByDepartmentProfile.do"
pagesize="10" cellpadding="2" cellspacing="2" decorator="com.krishct.efiler.user.documents.DownloadDecorator">
<display:column property="branch" title="Branch" sortable="true" style="text-align:center;" />
<display:column property="loginId" title="User Name"sortable="true" style="text-align:center;" />
<display:column title="View" style="text-align:center;">
<html:checkbox name="deptUsers" property="view" />
</display:column>
<display:column title="Review" style="text-align:center;">
<html:checkbox name="deptUsers" property="review" />
</display:column>
</display:table>

But this is not working.

I want the checkboxes get selected if the value from the database is true and others unchecked and if I select some other check boxes in different pages of the table and submit them they should be stored in database.

How to achieve this please guide me.

--regards,
raaja.g
Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84

Hi,

The bean class should have boolean property like "isChecked" and setter,getter pair as well. The value attribute will be assigned with unique loginid(please use if have some other unique id) for each checkbox. In selectUser() JS function, you can have logic for maintain the selected checkbox list. On submit form, the selected checkbox list(means uniqueid list) can be set in hidden field and obtain in action class. Below are the code snippets



In case of <input type="checkbox">

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make checkbox checked in display tag
 
Similar Threads
maintin checkbox stauts during paginatin(dispalytag)
How to pass multiple parameters. Displaytag row value not changing on dynamic link
Internationalization of display tag
How to add get the checkbox selected value from the display tag
Error while Exporting the display tag table content as a .pdf