|
From: Seth L. <se...@eh...> - 2004-05-19 03:01:00
|
Seth Ladd wrote:
> Oliver Hutchison wrote:
>
>> I have quite a few pages that have multiple forms in a single JSP so a
>> general <spring:bindFromCommand> wouldn't really work for me.
>> What I've found I'd like is something equivalent to the
>> Errors.setNestedPath() but for the bind tag. Perhaps
>> <spring:setNestedPath path="chooseBusinessTypeCommand">
>> <spring:bind path="type">
>> .. Do stuff
>> </spring:bind>
>> </spring:setNestedPath>
I have written some tag files (I love JSP 2.0 for tag files) that do
what we're talking about here. They also provide a wrapper for
<spring:bind> until the developers decide this is a useful feature to
integrate into the main code.
You can do:
<springx:setNestedPath path="beanName">
<springx:bind path="fieldName" /><br />
<springx:setNestedPath path="subBeanName">
<springx:bind path="subBeanFieldName" /><br />
<springx:setNestedPath path="subSubBeanName">
<springx:bind path="subSubFieldName"/><br/>
<springx:bind path="subSubFieldName2"/><br/>
</springx:setNestedPath>
</springx:setNestedPath>
<springx:bind path="anotherFieldName" /><br />
</springx:setNestedPath>
So you can nest and nest.
<springx:bind> just wraps <spring:bind> and takes the nestedPath value
and concatenates it with the path variable.
I'll post this to the wiki and if it works out, I'll submit it as an
improvement through JIRA.
Next up would be to bind in the name of the command object so that your
JSPs don't even have to know the command object name.
You could then do:
<springx:setNestedPath path="${commandName}">
...
</springx:setNestedPath>
Thanks for the idea!
Seth
ps Using this really cleans up the JSPs.
|