You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "zhouyanming (JIRA)" <ji...@apache.org> on 2010/04/19 09:37:51 UTC
[jira] Created: (WW-3441) support list ui tag bind data by
listValue beside by listKey
support list ui tag bind data by listValue beside by listKey
------------------------------------------------------------
Key: WW-3441
URL: https://issues.apache.org/jira/browse/WW-3441
Project: Struts 2
Issue Type: Improvement
Reporter: zhouyanming
list ui tag include select checkboxlist radio.
typically we use a enum values as list for those tag
package biz.model;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
public enum EmployeeType {
PACKER, DELIVERYMAN, WAREHOUSEMAN , SALESMAN, MANAGER, SERVANT;
public String getName() {
return name();
}
public String getDisplayName() {
return LocalizedTextUtil.findText(getClass(), name(), ActionContext
.getContext().getLocale(), name(), null);
}
public static EmployeeType parse(String name) {
if (name != null)
for (EmployeeType en : values())
if (name.equals(en.name()) || name.equals(en.getDisplayName()))
return en;
return null;
}
@Override //sometimes we need override toString() to display nicely
public String toString() {
return getDisplayName();
}
}
<@s.select name="employee.type" list="@biz.model.EmployeeType@values()" listKey="name" listValue="displayName" headerKey="" headerValue=""/>
I override enum's toString use displayName replace name,so currently struts2 can't bind data as selected
solution:
tag.contains(parameters.nameValue, itemKey) --> tag.contains(parameters.nameValue, itemKey) || tag.contains(parameters.nameValue, itemValue)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WW-3441) support list ui tag bind data by
listValue beside by listKey
Posted by "zhouyanming (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3441?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
zhouyanming updated WW-3441:
----------------------------
Attachment: patch.txt
> support list ui tag bind data by listValue beside by listKey
> ------------------------------------------------------------
>
> Key: WW-3441
> URL: https://issues.apache.org/jira/browse/WW-3441
> Project: Struts 2
> Issue Type: Improvement
> Reporter: zhouyanming
> Attachments: patch.txt
>
>
> list ui tag include select checkboxlist radio.
> typically we use a enum values as list for those tag
> package biz.model;
> import com.opensymphony.xwork2.ActionContext;
> import com.opensymphony.xwork2.util.LocalizedTextUtil;
> public enum EmployeeType {
> PACKER, DELIVERYMAN, WAREHOUSEMAN , SALESMAN, MANAGER, SERVANT;
> public String getName() {
> return name();
> }
> public String getDisplayName() {
> return LocalizedTextUtil.findText(getClass(), name(), ActionContext
> .getContext().getLocale(), name(), null);
> }
> public static EmployeeType parse(String name) {
> if (name != null)
> for (EmployeeType en : values())
> if (name.equals(en.name()) || name.equals(en.getDisplayName()))
> return en;
> return null;
> }
> @Override //sometimes we need override toString() to display nicely
> public String toString() {
> return getDisplayName();
> }
> }
> <@s.select name="employee.type" list="@biz.model.EmployeeType@values()" listKey="name" listValue="displayName" headerKey="" headerValue=""/>
> I override enum's toString use displayName replace name,so currently struts2 can't bind data as selected
> solution:
> tag.contains(parameters.nameValue, itemKey) --> tag.contains(parameters.nameValue, itemKey) || tag.contains(parameters.nameValue, itemValue)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.