File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Using checkbox & textfield together Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using checkbox & textfield together" Watch "Using checkbox & textfield together" New topic
Author

Using checkbox & textfield together

Craig Ricciuto
Greenhorn

Joined: Nov 05, 2009
Posts: 9
I've run into a little problem and with my limited knowledge in Struts 2 I've been unable to figure it out.

So I have an ArrayList of Strings being set in my action class and I can access it fine in the JSP via the Struts 2 tags (iterator with checkbox, OR using checkboxlist and no iterator). But I need an HTML text box input corresponding to each check box. So I want something that looks like the following once the HTML is rendered:



I've modified the checkboxlist tag once and have created my own "theme" that just has that change. I don't really want to do it again (create a second theme for another change to checkboxlist) unless I can modify my custom theme already to do what I currently have OR put a text box after the label.

Any ideas on how to use some kind of condition check in the FreeMarker checkboxlist.ftl file so after the label I can do what I'm already doing OR add the text field?

Thanks for any help. =)
Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
Is this what you wanted.
If there are 10 values in ArrayList, then you needed 10 checkboxes and 10 textboxes where one checkbox and one textbox in a row.
So there will be 10 rows.
Craig Ricciuto
Greenhorn

Joined: Nov 05, 2009
Posts: 9
Yes. That's exactly what I want. Again though, I have modified the checkboxlist template once so if there is some kind of condition check I can make (I've tried once but failed. It's still a little bit beyond my understanding) to either do what I already modified to do after the label OR add the text box that would be fantastic.
Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
This can be achieved by using Iterator tags in JSP

Action



JSP
Craig Ricciuto
Greenhorn

Joined: Nov 05, 2009
Posts: 9
Ah I'm an idiot sometimes. I was just trying to use the struts2 tags to do it...was so dead set on that that I didn't even think about just using normal HTML. Gah!
Yay for overcomplicating things. I need to work on that.

Thanks Kartik.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using checkbox & textfield together