You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Agoston Bejo <be...@yahoo.com> on 2011/01/28 10:25:05 UTC

Struts2 question: ModelDriven +


Hey there,

here's my problem:

a) the action:
public class SomeAction ... implements ModelDriven<SomeModel> { ...
public SomeModel getModel() {...}
... }

b) the model:
public class SomeModel implements Serializable {
...
public List<Map.Entry<String, String>> getMessageTypes() { ... }
public String getRaggedyAndy() { ... }
... }

c) in the jsp:

<s:textfield ... name="raggedyAndy" />
<%-- works, finds the model object in the value stack and uses its 
getters/setters --%>

BUT:

<s:select list="messageTypes" listKey="key" listValue="value" ... />
results in:

...
Caused by: tag 'select', field 'list', name 'messageType': The requested
list key 'messageTypes' could not be resolved as a
collection/array/map/enumeration/iterator type. Example: people or
people.{name} - [unknown location]
at
org.apache.struts2.components.Component.fieldError(Component.java:231)
at org.apache.struts2.components.Component.findValue(Component.java:293)
at
org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:79)
at
org.apache.struts2.components.Select.evaluateExtraParams(Select.java:99)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:780)
at org.apache.struts2.components.UIBean.end(UIBean.java:481)
at
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)





Although if I understand the spec. correctly, it should also find the
model object on the value stack and use its corresponding getter. I've
even added a getter with the same name (returning eventually physically
the same list) but it doesn't make any difference.

Note: one might argue that the return type of the getter is too
"strange" but according to the specification it should be fine (I also
tried with a simple map first btw.) and the getter "getMessageTypes()"
isn't even called at all anyway.


Thanks for any help,
Agoston


      

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