[S2] How to add a custom parameter to an existing Struts UI Tag?
I am trying to override a struts tag template (specifically s:checkboxlist), and I can't figure out how to add a parameter to the tag. I have successfully overridden the template by copying checkboxlist.tld to my template/simple directory and all works well. Now I would like to add a parameter. It appears that I need to override the the META-INF/struts-tags.tld file because I keep getting the error below. However, using the same method as checkboxlist.tld, I copy a modified version of struts-tags.tld to my META-INF/struts-tags.tld directory. However, I still get the same error below. Not sure if I need to modify another file or if struts-tags.tld cannot be overridden. Anyone given this a try? Trying not to have to create a new custom tag since all I want is a simple modification to checkboxlist.tld. ERROR /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD Caused by: org.apache.jasper.JasperException: /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD --- Tag with added parameter (breakCount): s:checkboxlist name=ownerIds list=%{activeAppUserList} listKey=appUserId listValue=nameInformal required=true breakCount=3 !-- New Parameter, will enter the breakString after every 3 items -- breakString=br/ / Excerpt from modified struts-tags.tld: tag description![CDATA[Render a list of checkboxes]]/description namecheckboxlist/name tag-classorg.apache.struts2.views.jsp.ui.CheckboxListTag/tag-class body-contentJSP/body-content attribute description![CDATA[Set the html accesskey attribute on rendered html element]]/description nameaccesskey/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute description![CDATA[Number of elements to display before inserting 'break' element.]]/description namebreakCount/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute description![CDATA[Used to override the default 'break' string. Default is br.]]/description namebreakString/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Do you need to insert a breaking string every 3 items? I think this approach is too much expansive in term of time. Furthermore, after that, you should deal with subcassing process. You should have valid reasons for do that. Why don't you simply use mod operator?: s:iterator status=stat value={1,2,3,4,5} s:if test=(#stat.index % 3)==0 insert breaking string /s:if . /s:iterator Maurizio Cucchiara 2010/10/9 Burton Rhodes burtonrho...@gmail.com: I am trying to override a struts tag template (specifically s:checkboxlist), and I can't figure out how to add a parameter to the tag. I have successfully overridden the template by copying checkboxlist.tld to my template/simple directory and all works well. Now I would like to add a parameter. It appears that I need to override the the META-INF/struts-tags.tld file because I keep getting the error below. However, using the same method as checkboxlist.tld, I copy a modified version of struts-tags.tld to my META-INF/struts-tags.tld directory. However, I still get the same error below. Not sure if I need to modify another file or if struts-tags.tld cannot be overridden. Anyone given this a try? Trying not to have to create a new custom tag since all I want is a simple modification to checkboxlist.tld. ERROR /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD Caused by: org.apache.jasper.JasperException: /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD --- Tag with added parameter (breakCount): s:checkboxlist name=ownerIds list=%{activeAppUserList} listKey=appUserId listValue=nameInformal required=true breakCount=3 !-- New Parameter, will enter the breakString after every 3 items -- breakString=br/ / Excerpt from modified struts-tags.tld: tag description![CDATA[Render a list of checkboxes]]/description namecheckboxlist/name tag-classorg.apache.struts2.views.jsp.ui.CheckboxListTag/tag-class body-contentJSP/body-content attribute description![CDATA[Set the html accesskey attribute on rendered html element]]/description nameaccesskey/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute description![CDATA[Number of elements to display before inserting 'break' element.]]/description namebreakCount/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute description![CDATA[Used to override the default 'break' string. Default is br.]]/description namebreakString/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
I think encapsulating this kind of behavior in a custom tag is why custom tags exist--and since the iteration is handled by the checkboxlist tag internally, using an iterator/etc. doesn't really work. Dave On Saturday, October 9, 2010, Maurizio Cucchiara maurizio.cucchi...@gmail.com wrote: Do you need to insert a breaking string every 3 items? I think this approach is too much expansive in term of time. Furthermore, after that, you should deal with subcassing process. You should have valid reasons for do that. Why don't you simply use mod operator?: s:iterator status=stat value={1,2,3,4,5} s:if test=(#stat.index % 3)==0 insert breaking string /s:if . /s:iterator Maurizio Cucchiara 2010/10/9 Burton Rhodes burtonrho...@gmail.com: I am trying to override a struts tag template (specifically s:checkboxlist), and I can't figure out how to add a parameter to the tag. I have successfully overridden the template by copying checkboxlist.tld to my template/simple directory and all works well. Now I would like to add a parameter. It appears that I need to override the the META-INF/struts-tags.tld file because I keep getting the error below. However, using the same method as checkboxlist.tld, I copy a modified version of struts-tags.tld to my META-INF/struts-tags.tld directory. However, I still get the same error below. Not sure if I need to modify another file or if struts-tags.tld cannot be overridden. Anyone given this a try? Trying not to have to create a new custom tag since all I want is a simple modification to checkboxlist.tld. ERROR /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD Caused by: org.apache.jasper.JasperException: /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD --- Tag with added parameter (breakCount): s:checkboxlist name=ownerIds list=%{activeAppUserList} listKey=appUserId listValue=nameInformal required=true breakCount=3 !-- New Parameter, will enter the breakString after every 3 items -- breakString=br/ / Excerpt from modified struts-tags.tld: tag description![CDATA[Render a list of checkboxes]]/description namecheckboxlist/name tag-classorg.apache.struts2.views.jsp.ui.CheckboxListTag/tag-class body-contentJSP/body-content attribute description![CDATA[Set the html accesskey attribute on rendered html element]]/description nameaccesskey/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute description![CDATA[Number of elements to display before inserting 'break' element.]]/description namebreakCount/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute description![CDATA[Used to override the default 'break' string. Default is br.]]/description namebreakString/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Dave you're right, I was not clear I'll try to explain better: s:iterator status=stat value=list s:checkbox label=checkbox label name=checkboxName value=checkboxValue/ s:if test=(#stat.index % 3)==0 insert breaking string /s:if Maurizio Cucchiara 2010/10/9 Dave Newton davelnew...@gmail.com: I think encapsulating this kind of behavior in a custom tag is why custom tags exist--and since the iteration is handled by the checkboxlist tag internally, using an iterator/etc. doesn't really work. Dave On Saturday, October 9, 2010, Maurizio Cucchiara maurizio.cucchi...@gmail.com wrote: Do you need to insert a breaking string every 3 items? I think this approach is too much expansive in term of time. Furthermore, after that, you should deal with subcassing process. You should have valid reasons for do that. Why don't you simply use mod operator?: s:iterator status=stat value={1,2,3,4,5} s:if test=(#stat.index % 3)==0 insert breaking string /s:if . /s:iterator Maurizio Cucchiara 2010/10/9 Burton Rhodes burtonrho...@gmail.com: I am trying to override a struts tag template (specifically s:checkboxlist), and I can't figure out how to add a parameter to the tag. I have successfully overridden the template by copying checkboxlist.tld to my template/simple directory and all works well. Now I would like to add a parameter. It appears that I need to override the the META-INF/struts-tags.tld file because I keep getting the error below. However, using the same method as checkboxlist.tld, I copy a modified version of struts-tags.tld to my META-INF/struts-tags.tld directory. However, I still get the same error below. Not sure if I need to modify another file or if struts-tags.tld cannot be overridden. Anyone given this a try? Trying not to have to create a new custom tag since all I want is a simple modification to checkboxlist.tld. ERROR /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD Caused by: org.apache.jasper.JasperException: /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD --- Tag with added parameter (breakCount): s:checkboxlist name=ownerIds list=%{activeAppUserList} listKey=appUserId listValue=nameInformal required=true breakCount=3 !-- New Parameter, will enter the breakString after every 3 items -- breakString=br/ / Excerpt from modified struts-tags.tld: tag description![CDATA[Render a list of checkboxes]]/description namecheckboxlist/name tag-classorg.apache.struts2.views.jsp.ui.CheckboxListTag/tag-class body-contentJSP/body-content attribute description![CDATA[Set the html accesskey attribute on rendered html element]]/description nameaccesskey/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute description![CDATA[Number of elements to display before inserting 'break' element.]]/description namebreakCount/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute description![CDATA[Used to override the default 'break' string. Default is br.]]/description namebreakString/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Much cleaner to encapsulate the behavior, especially if it's used often. It might be easier to use a JSP-based tag, though, than to extend an S2 tag. On Saturday, October 9, 2010, Maurizio Cucchiara maurizio.cucchi...@gmail.com wrote: Dave you're right, I was not clear I'll try to explain better: s:iterator status=stat value=list s:checkbox label=checkbox label name=checkboxName value=checkboxValue/ s:if test=(#stat.index % 3)==0 insert breaking string /s:if Maurizio Cucchiara 2010/10/9 Dave Newton davelnew...@gmail.com: I think encapsulating this kind of behavior in a custom tag is why custom tags exist--and since the iteration is handled by the checkboxlist tag internally, using an iterator/etc. doesn't really work. Dave On Saturday, October 9, 2010, Maurizio Cucchiara maurizio.cucchi...@gmail.com wrote: Do you need to insert a breaking string every 3 items? I think this approach is too much expansive in term of time. Furthermore, after that, you should deal with subcassing process. You should have valid reasons for do that. Why don't you simply use mod operator?: s:iterator status=stat value={1,2,3,4,5} s:if test=(#stat.index % 3)==0 insert breaking string /s:if . /s:iterator Maurizio Cucchiara 2010/10/9 Burton Rhodes burtonrho...@gmail.com: I am trying to override a struts tag template (specifically s:checkboxlist), and I can't figure out how to add a parameter to the tag. I have successfully overridden the template by copying checkboxlist.tld to my template/simple directory and all works well. Now I would like to add a parameter. It appears that I need to override the the META-INF/struts-tags.tld file because I keep getting the error below. However, using the same method as checkboxlist.tld, I copy a modified version of struts-tags.tld to my META-INF/struts-tags.tld directory. However, I still get the same error below. Not sure if I need to modify another file or if struts-tags.tld cannot be overridden. Anyone given this a try? Trying not to have to create a new custom tag since all I want is a simple modification to checkboxlist.tld. ERROR /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD Caused by: org.apache.jasper.JasperException: /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD --- Tag with added parameter (breakCount): s:checkboxlist name=ownerIds list=%{activeAppUserList} listKey=appUserId listValue=nameInformal required=true breakCount=3 !-- New Parameter, will enter the breakString after every 3 items -- breakString=br/ / Excerpt from modified struts-tags.tld: tag description![CDATA[Render a list of checkboxes]]/description namecheckboxlist/name tag-classorg.apache.struts2.views.jsp.ui.CheckboxListTag/tag-class body-contentJSP/body-content attribute description![CDATA[Set the html accesskey attribute on rendered html element]]/description nameaccesskey/name requiredfalse/required rtexprvaluefalse/rtexprvalue /attribute attribute - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Agreed. I think an upgrade to the checklistbox tag is in warranted. Through my searches there are many posts looking for ways to layout the checkboxlist better. Most frustrating on this tag is the actual checkbox and the label will break lines making this unacceptable from a UI perspective. Also, many users I saw just wanted a one column format. I would propose surrounding the input type=checkbox and label html elements in a div tag (you could even supply an additional class and style attribute to the tag). This way a user could set widths, floats, etc for the div tag. This hack below did the trick for me. By setting the div Class properties: float in combination with width you can easily set up one column lists or fixed width layouts that extend to the next line easily. Would make this tag much more versatile - especially with just a small modification. #-- Modified checklistbox.tld with surrounding div tag -- div class=myCustomDivClass input type=checkbox name=${parameters.name?html} value=${itemKeyStr?html} id=${parameters.name?html}-${itemCount}#rt/ #if tag.contains(parameters.nameValue, itemKey) checked=checked#rt/ /#if #if parameters.disabled?default(false) disabled=disabled#rt/ /#if #if parameters.title?? title=${parameters.title?html}#rt/ /#if #include /${parameters.templateDir}/simple/scripting-events.ftl / #include /${parameters.templateDir}/simple/common-attributes.ftl / / label for=${parameters.name?html}-${itemCount} class=checkboxLabel${itemValue?html}/label #-- Add ending div tag -- /div On Sat, Oct 9, 2010 at 3:08 PM, Dave Newton davelnew...@gmail.com wrote: Much cleaner to encapsulate the behavior, especially if it's used often. It might be easier to use a JSP-based tag, though, than to extend an S2 tag. On Saturday, October 9, 2010, Maurizio Cucchiara maurizio.cucchi...@gmail.com wrote: Dave you're right, I was not clear I'll try to explain better: s:iterator status=stat value=list s:checkbox label=checkbox label name=checkboxName value=checkboxValue/ s:if test=(#stat.index % 3)==0 insert breaking string /s:if Maurizio Cucchiara 2010/10/9 Dave Newton davelnew...@gmail.com: I think encapsulating this kind of behavior in a custom tag is why custom tags exist--and since the iteration is handled by the checkboxlist tag internally, using an iterator/etc. doesn't really work. Dave On Saturday, October 9, 2010, Maurizio Cucchiara maurizio.cucchi...@gmail.com wrote: Do you need to insert a breaking string every 3 items? I think this approach is too much expansive in term of time. Furthermore, after that, you should deal with subcassing process. You should have valid reasons for do that. Why don't you simply use mod operator?: s:iterator status=stat value={1,2,3,4,5} s:if test=(#stat.index % 3)==0 insert breaking string /s:if . /s:iterator Maurizio Cucchiara 2010/10/9 Burton Rhodes burtonrho...@gmail.com: I am trying to override a struts tag template (specifically s:checkboxlist), and I can't figure out how to add a parameter to the tag. I have successfully overridden the template by copying checkboxlist.tld to my template/simple directory and all works well. Now I would like to add a parameter. It appears that I need to override the the META-INF/struts-tags.tld file because I keep getting the error below. However, using the same method as checkboxlist.tld, I copy a modified version of struts-tags.tld to my META-INF/struts-tags.tld directory. However, I still get the same error below. Not sure if I need to modify another file or if struts-tags.tld cannot be overridden. Anyone given this a try? Trying not to have to create a new custom tag since all I want is a simple modification to checkboxlist.tld. ERROR /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD Caused by: org.apache.jasper.JasperException: /contact/contactCreate.jsp(286,6) PWC6131: Attribute breakCount invalid for tag checkboxlist according to TLD --- Tag with added parameter (breakCount): s:checkboxlist name=ownerIds list=%{activeAppUserList} listKey=appUserId listValue=nameInformal required=true breakCount=3 !-- New Parameter, will enter the breakString after every 3 items -- breakString=br/ / Excerpt from modified struts-tags.tld: tag description![CDATA[Render a list of checkboxes]]/description namecheckboxlist/name tag-classorg.apache.struts2.views.jsp.ui.CheckboxListTag/tag-class body-contentJSP/body-content attribute description![CDATA[Set the html accesskey attribute on rendered html element]]/description nameaccesskey/name requiredfalse/required rtexprvaluefalse/rtexprvalue
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Hello all, I am trying to create my struts2 UI-Tag too. Did you change the org.apache.struts2.views.jsp.ui.CheckboxListTag to your rewritten the Tag-class and the correspond CheckboxList yet? Regards, Mead
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
I mean in the modified struts-tags.tld: namecheckboxlist/name tag-classorg.apache.struts2.views.jsp.ui.CheckboxListTag/tag-class body-contentJSP/body-content It seems nothing changed about the tag-class
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
I ended up not having to create a new tag. I simply overrode the current template (template/simple/checkboxlist.tld) to do what I wanted. Essentially I just did what it says on this page entitled Creating And Applying Your Own Themes For Struts 2 Tags: http://struts.apache.org/2.2.1/docs/struts-2-themes.html On Sat, Oct 9, 2010 at 4:58 PM, Mead Lai laiqi...@gmail.com wrote: Hello all, I am trying to create my struts2 UI-Tag too. Did you change the org.apache.struts2.views.jsp.ui.CheckboxListTag to your rewritten the Tag-class and the correspond CheckboxList yet? Regards, Mead - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Hi Burton, I see, that would be the problem cause that ERROR. You have to download the struts2 source, and take a look at the both org.apache.struts2.views.jsp.ui.CheckboxListTag and org.apache.struts2.components,CheckboxList. I think you must add the attribute breakCount into CheckboxList.java, then it will work, maybe. I am not sure about that, I am also got the same problem, when creating myself Tag. Good Luck. Regards, Mead On Sun, Oct 10, 2010 at 6:04 AM, Burton Rhodes burtonrho...@gmail.comwrote: I ended up not having to create a new tag. I simply overrode the current template (template/simple/checkboxlist.tld) to do what I wanted. Essentially I just did what it says on this page entitled Creating And Applying Your Own Themes For Struts 2 Tags: http://struts.apache.org/2.2.1/docs/struts-2-themes.html On Sat, Oct 9, 2010 at 4:58 PM, Mead Lai laiqi...@gmail.com wrote: Hello all, I am trying to create my struts2 UI-Tag too. Did you change the org.apache.struts2.views.jsp.ui.CheckboxListTag to your rewritten the Tag-class and the correspond CheckboxList yet? Regards, Mead - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Thanks for the email. I was afraid it might be a bit more involved. I will probably shy away from that sort of surgery. Once you start modifying the Struts source, it can make future Struts upgrades painful. On Sat, Oct 9, 2010 at 5:26 PM, Mead Lai laiqi...@gmail.com wrote: Hi Burton, I see, that would be the problem cause that ERROR. You have to download the struts2 source, and take a look at the both org.apache.struts2.views.jsp.ui.CheckboxListTag and org.apache.struts2.components,CheckboxList. I think you must add the attribute breakCount into CheckboxList.java, then it will work, maybe. I am not sure about that, I am also got the same problem, when creating myself Tag. Good Luck. Regards, Mead On Sun, Oct 10, 2010 at 6:04 AM, Burton Rhodes burtonrho...@gmail.comwrote: I ended up not having to create a new tag. I simply overrode the current template (template/simple/checkboxlist.tld) to do what I wanted. Essentially I just did what it says on this page entitled Creating And Applying Your Own Themes For Struts 2 Tags: http://struts.apache.org/2.2.1/docs/struts-2-themes.html On Sat, Oct 9, 2010 at 4:58 PM, Mead Lai laiqi...@gmail.com wrote: Hello all, I am trying to create my struts2 UI-Tag too. Did you change the org.apache.struts2.views.jsp.ui.CheckboxListTag to your rewritten the Tag-class and the correspond CheckboxList yet? Regards, Mead - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Hi Burton: The error message looks like the TLD file does not defined the new attribute correctly. So i think maybe the execute environment is not using the modified TLD file but the old one. Can you show us how you do apply your TLD file to the execute environment? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org