Better BeanFirstPopulationStrategy: If bean value is null, look for value in
request and then use value from tag
----------------------------------------------------------------------------------------------------------------
Key: STS-818
URL: http://www.stripesframework.org/jira/browse/STS-818
Project: Stripes
Issue Type: Improvement
Components: ActionBean Dispatching
Affects Versions: Release 1.5.6
Reporter: Haggi
Attachments: BeanRequestTagPopulationStrategy.java
I have some trouble while using indexed properties and use the value attribute
within the jsp.
Let me explain my problem:
The BeanFirstPopulationStrategy implementation looks first for a defined
attribute with the same name supplied to the tag.
If the attribute exists the value, even if it's null will be returned. So if
you set the value attribute of the tag within the jsp, this value will be
ignored.
Usually it's not a problem, when you set the default value within the action
bean. But if you want to use indexed properties like you explain in your
tutorials it's not possible to use the value attribute for default values. You
have to set the default values within your ActionBean.
This example won't work with BeanFirstPopulationStrategy
<c:forEach items="${persons}" var="person" varStatus="loop">
<tr>
<td>
<stripes:hidden name="people[${loop.index}].id"
value="${person.id}"/>
</td>
<td>
<stripes:text name="people[${loop.index}].username"
value="${person.username}"/>
</td>
</tr>
</c:forEach>
My solution:
I think a better way for a population strategy is looking first if an attribute
exists within the action bean, if it is null check the request and finally
check the value attribute on the page. So you can define your default values in
the action bean, or in the request or on the tag.
I have attached a new PopulationStrategy Class called
BeanRequestTagPopulationStrategy which implements the described process.
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development