Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make checkbox checked in display tag

 
Raaja Gotluru
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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">

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic