Struts2 cssclass:struts2 CheckBoxList Label Settings CssClass Property The check does not have a class attribute problem in the HTML code generated
Last Update:2017-02-28
Source: Internet
Author: User
After you set the CssClass property with the Struts2 CheckBoxList tab, you find that the input tag in the generated HTML code does not have a class attribute.
Open CHECKBOXLIST.FTL Look, the contents are as follows:
<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"/>
/>
No CssClass parameters are set at all.
Add the following, in the replacement struts2 package
Checkboxlist.ftl
The file is OK:
< #if parameters.cssclass?? >
class= "${parameters.cssclass?html}" < #rt/>
</#if >
The complete FTL file is as follows:
< #assign ItemCount = 0/>
< #if parameters.list?? >
<@s.iterator value= "Parameters.list" >
< #assign ItemCount = ItemCount + 1/>
< #if Parameters.listkey?? >
< #assign Itemkey = Stack.findvalue (Parameters.listkey)/>
< #else >
< #assign Itemkey = Stack.findvalue (' top ')/>
</#if >
< #if parameters.listvalue?? >
< #assign Itemvalue = stack.findstring (parameters.listvalue)? Default ("")/>
< #else >
< #assign Itemvalue = stack.findstring (' top ')/>
</#if >
< #assign itemkeystr=itemkey.tostring ()/>
<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 >
< #if parameters.cssclass?? >
class= "${parameters.cssclass?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>
</@s.iterator>
< #else >
</#if >
<input type= "hidden" id= "__multiselect_${parameters.id?html}" Name= "__multiselect_${parameters.name?html}" Value= "" < #rt/>
< #if Parameters.disabled?default (false) >
disabled= "Disabled" < #rt/>
</#if >
/> This article links http://www.cxybl.com/html/wyzz/CSS/20130806/39524.html