struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <davelnew...@gmail.com>
Subject Re: [S2] How to add a custom parameter to an existing Struts UI Tag?
Date Sat, 09 Oct 2010 20:08:56 GMT
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.cucchiara@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 <davelnewton@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.cucchiara@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 <burtonrhodes@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>
>>>>    <name>checkboxlist</name>
>>>>    <tag-class>org.apache.struts2.views.jsp.ui.CheckboxListTag</tag-class>
>>>>    <body-content>JSP</body-content>
>>>>    <attribute>
>>>>      <description><![CDATA[Set the html accesskey attribute on
>>>> rendered html element]]></description>
>>>>      <name>accesskey</name>
>>>>      <required>false</required>
>>>>      <rtexprvalue>false</rtexprvalue>
>>>>    </attribute>
>>>>    <attribute>
>>>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message