Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mutlibox in a table

Status
Not open for further replies.

dcusick

Technical User
Aug 9, 2000
271
US
What's up all? Okay, this is what I have so far.. I have an action that accesses a DB, and populates a LabelValueBean with an ID and a name. I use this LVB to create a multibox in my jsp page. This is working no problem and I can tick a few checkboxes and get the values of the checked boxes. However, here in lies the challenge.. I need to add another column to the table. Currently the table has one column for the checkbox and one column for the label. I want to add a third column that also grabs data from the database. I know that LVB's only store an ID and a label. I now need to store a third entity. What should I use to achieve this? I still need to have the multibox but need a third piece of data. Any ideas or suggestions? Thanks in advance..

Doug
 
Hi,

I am really not sure about what you are tying to do with the 3 param on the Jsp page. Try this, Insted of using the LabelValueBean(String, String) write your own bean which accepts three string.

Ex:

public class MultiBoxBean {

private String id;
private String label;
private String param;

public MultiBoxBean(String id, String label, String param) {
this.id = id;
this.label = label;
this.param = param;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getLabel() {
return label;
}

public void setLabel(String label) {
this.label = label;
}

public String getParam() {
return param;
}

public void setParam(String param) {
this.param = param;
}
}

In the action Class you can set the request Attribute as

ArrayList list = new ArrayList();
list.add(new MultiBoxBean("1","One","Hello"));
list.add(new MultiBoxBean("2","Tow","How"));
list.add(new MultiBoxBean("3","Three","Are"));
list.add(new MultiBoxBean("4","Four","You!"));
httpServletRequest.setAttribute("listBean", list);

In the Jsp Page you can access the list for multibox

<logic:iterate name=&quot;listBean&quot; id=&quot;list&quot;>
<html:multibox name=&quot;list&quot; property=&quot;id&quot; >
<bean:write name=&quot;list&quot; property=&quot;label&quot; />
</html:multibox>
<bean:write name=&quot;list&quot; property=&quot;param&quot; /><br />
</logic:iterate>

Hope this will help you.

Cheers,
Venu
 
That would make perfect sense... I actually talked to a colleague of mine who is working on this project with me about this. He told me that we already had a bean that took care of a few of the items I needed. I just added a new getter and setter method for the third parameter I needed and all is well! Thanks for the advice, it's exactly what I ended up with in the end...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top