[
https://issues.apache.org/jira/browse/WW-4987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16708424#comment-16708424
]
Muhammad Salman commented on WW-4987:
-------------------------------------
Hi [~yasser.zamani]
Here is the JSP snippit from Struts Version 2.2.3
{code}
<s:select list="#\{'none':'-Select Template-'}" id="export-data"
cssStyle="width:250px;" title="templateDesc" cssClass="templateType"
onchange="adjustReportText()" name="templateID">
<s:iterator value="\{SOME MAP WITH KEY AND LIST OF VALUES}" var="TG"
status="stat">
<s:optgroup label="%\{key}" list="%\{value}"
listKey="templateId" listValue="templateName" ></s:optgroup>
</s:iterator>
</s:select>
{code}
Here is its generated HTML:
{code}
<select name="templateID" id="export-data" class="templateType"
style="width:250px;" onchange="adjustReportText()">
<option title="--Select Template--" value="none"
class="templateType">--Select Template--</option>
<optgroup label="GROUP NO 1">
<option value="3223" title="" class="cssClass1"> ... </option>
<option value="3341" title="" class="cssClass1"> ... </option>
</optgroup>
<optgroup label="GROUP NO 2">
<option value="2465" title="Executive dashboard"
class="cssClass2"> ... </option>
</optgroup>
<optgroup label="GROUP NO 3">
<option value="2749" class="cssClass3"> ... </option>
<option value="2464" class="cssClass3"> ... </option>
</optgroup>
</select>
{code}
Here you can see in the generated HTML, the class attribute is added to
<option> tag within <optgroup> when I provided cssClass attribute in
<s:select>. Thats what I was expecting in later versions of struts as well, but
came across that now for <option> tag, we have *listCssClass* attribute in
<s:select> which would add class attribute to <option> tag if <option> tag is
not enclosed within <optgroup>.
> Setting Struts2 <s:select> options Css Class
> --------------------------------------------
>
> Key: WW-4987
> URL: https://issues.apache.org/jira/browse/WW-4987
> Project: Struts 2
> Issue Type: Bug
> Components: Core Tags
> Affects Versions: 2.5.17
> Reporter: Muhammad Salman
> Assignee: Aleksandr Mashchenko
> Priority: Major
> Fix For: 2.6, 2.5.19
>
> Attachments: struts.log
>
>
> Hi
> I am working on an application that is built on struts 2.5.17. I have
> {{<s:select>}} tag with <optgroup> and <option>. I am trying to add cssClass
> to <options> under <optgroup>. I am trying to add css class to <option> using
> listCssClass attribute of {{<s:select>}} but it is not adding class to the
> <option>. Any help would be much appreciated.
> Here is code from my JSP:
> {code:xml}
> <s:select list="#\{'none':'-Select Template-'}" id="export-data"
> cssStyle="width:250px;" title="templateDesc" cssClass="templateType"
> onchange="adjustReportText()" name="templateID" listCssClass="templateType">
> <s:iterator value="\{SOME MAP WITH KEY AND LIST OF VALUES}" var="TG"
> status="stat">
> <s:optgroup label="%\{key}" list="%\{value}" listKey="templateId"
> listValue="templateName" ></s:optgroup>
> </s:iterator>
> </s:select>
> {code}
> Initially we were working on struts 2.2.3 version and in that version,
> cssClass attribute populates the CSS Class for <option>, but in 2.5.17
> neither cssClass is populated class to <option> nor listCssClass.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)