This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes struts2 custom components checkbox JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 custom components checkbox JSP" Watch "struts2 custom components checkbox JSP" New topic
Author

struts2 custom components checkbox JSP

vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
Hello All,

actually i wanted to place a check box in iterator tag for each row to provide mutiple edit facility, and i am unable to do it with <s:checkbox>,i think this can be done with custom components.
i wanted to know what are steps to create a custom component in struts for JSP.
however i have done a lot of googling but didn't get some solid document regarding custom components.


Thanks
Vijay Saraf.
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
Bazzzzz......... Ranchers..........
i will appreciate even a link of custom component.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please see EaseUp and PatienceIsAVirtue.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why can't you just use a checkbox tag? If you're wrapping up the HTML inside an iterator I don't see what the issue is.
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
Ohh!!! I am sorry and definitely i will wait at least for a day to get the answer.

Why can't you just use a checkbox tag? If you're wrapping up the HTML inside an iterator I don't see what the issue is


i agree with you but i was looking inside struts to achive that...

ok i have done like this...



and it means we can't completely omit the old HTML tags...
any ways ...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I still don't see what the issue is with using an S2 tag, but there's also no reason not to use straight HTML when it works (unless you need to display the values pre-populated).
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
OK Mr. David,
Actually , i have declared a selectedIndex as List<Integer> in my action and want to collect those selected Indexes
and more with this is, till date i am not clear about Indexed property in S2.
and as per my understanding checkbox value in struts2 must be boolean like [please correct me if i am wrong]
<s:checkbox value="boolean" />
but in html i can supply any string type value...and OGNL convert and populate this selectedIndex List for me...
If you can please show me the code sample useing S2 checkbox, i will be thankful to you.


Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Hi vijay saraf,

I think this is what you are asking for.

---
A.A.Anbarasu


A.A.Anbarasu
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
Thanks Aladiyan & David,
Actually i was not awre of fieldValue.
I have done that using filedValue attribute of s:checkbox,


where employees is a List<EmployeeBean> and seletedIndex is a List<Integer>.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts2 custom components checkbox JSP
 
Similar Threads
If i dont do custom tags??
framework comparisons
Migrating to JSF 2.0
UI - Bundling custom components.
To Hans: Difference between Struts and JSF