struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Muhammad Salman (JIRA)" <>
Subject [jira] [Commented] (WW-4987) Setting Struts2 <s:select> options Css Class
Date Thu, 29 Nov 2018 06:55:00 GMT


Muhammad Salman commented on WW-4987:

Hi [~aleksandr-m]
I have tried your proposed solution, here is what I did:

								list="#{'none':'--Select Template--'}"
							<s:iterator value="%{'inventory',#session.pro_user)}"
var="TG" status="stat">
								<optgroup label="<s:property value='key' />" list="%{value}" listKey="templateId"
listValue="templateName" ></optgroup>

Here is the output HTML Being generated by jsp : 

<optgroup label="Cognos Reports" list="%{value}" listkey="templateId" listvalue="templateName"></optgroup>
								<optgroup label="Executive Dashboard" list="%{value}" listkey="templateId" listvalue="templateName"></optgroup>
								<optgroup label="Global Priority Reports" list="%{value}" listkey="templateId"
								<optgroup label="Global Reports" list="%{value}" listkey="templateId" listvalue="templateName"></optgroup>
								<optgroup label="Inventory Upload Report" list="%{value}" listkey="templateId"
								<optgroup label="Miscellaneous" list="%{value}" listkey="templateId" listvalue="templateName"></optgroup>
								<select name="templateID" id="export-data" class="templateType" style="width:250px;"
title="templateDesc" onchange="adjustReportText()">
									<option value="none">--Select Template--</option>

I know that the {color:red}list="%{value}" listKey="templateId" listValue="templateName" {color}
should not go as is in the <optgroup> tag but If I remove these values then how would
struts taglib know that this particular option would go into that particular <optgroup>

Let me share with you my datastructure as well which I am using to populate s:select which
was working in struts 2.2.3:

{code:xml}Map<String,List<Template>> map = new LinkedHashMap<String,List<Template>>();{code}

Now I hope you can related this data-structure to my orignal <s:select> defination.

> Setting Struts2 <s:select> options Css Class
> --------------------------------------------
>                 Key: WW-4987
>                 URL:
>             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
> 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"
> <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: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

View raw message