|
From: Oliver H. <Ol...@ou...> - 2004-05-18 01:05:55
|
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.=20
What I've found I'd like is something equivalent to the
Errors.setNestedPath() but for the bind tag. Perhaps=20
<spring:setNestedPath path=3D"chooseBusinessTypeCommand">
<spring:bind path=3D"type">
.. Do stuff
</spring:bind>
</spring:setNestedPath>=20
This gets really useful when you start reusing parts of your form. Then
you could do stuff like
<spring:setNestedPath path=3D"editBusinessUser">
<spring:bind path=3D"type">
.. Do stuff
</spring:bind>
<spring:setNestedPath path=3D"internalContact">
<%@ include file=3D"/include/forms/contact_form.jsp" %>
</spring:setNestedPath>
<spring:setNestedPath path=3D"externalContact">
<%@ include file=3D"/include/forms/contact_form.jsp" %>
</spring:setNestedPath>
</spring:setNestedPath>
At the moment I pass a variable around which holds the nested path but
using tags would feel much better.
> -----Original Message-----
> From: spr...@li...=20
> [mailto:spr...@li...]
> On Behalf Of Seth Ladd
> Sent: Tuesday, 18 May 2004 10:18 AM
> To: spr...@li...
> Subject: [Springframework-developer] Way to streamline=20
> spring:bind usage?
>=20
>=20
> Hello,
>=20
> I've been pooring over the source today trying to find out a=20
> way around=20
> this, but no luck. I'm hoping others could lend a hand.
>=20
> In converting all of our struts code to Spring, I'm writing a lot of=20
> <spring:bind> tags. While binding to a particular field, I=20
> have to use=20
> the commandName + fieldName with spring:bind. Typical usage is:
>=20
> <spring:bind path=3D"chooseBusinessTypeCommand.type">
> <springx:fieldLabel name=3D"chooseBusinessTypeCommand.type"/>
> <f:select name=3D"${status.expression}"=20
> value=3D"${status.value}"> <f:option value=3D"">----</f:option>=20
> <f:option value=3D"SP"><fmt:message=20
> key=3D"bizType.SP"/></f:option> <f:option=20
> value=3D"DC"><fmt:message key=3D"bizType.DC"/></f:option>=20
> </f:select> </spring:bind> </div>
>=20
> (Note that <f:select> and <f:option> are tagfiles emulating=20
> the struts=20
> <html:select> and <html:option> tags).
>=20
> My question is, is there a nice way to omit the=20
> "chooseBusinessTypeCommand" usage from the JSP file? I write=20
> that for=20
> every field in the form. Ideally the tags would read that from the=20
> handler somehow, where the commandName is initially specified.
>=20
> I could specify it once at the top of the file, but I'd=20
> really like to=20
> not specify it at all.
>=20
> I realize that keeping it this way keeps <spring:bind> more flexible,=20
> but I would guess that nearly all usage would be to bind to=20
> the form and=20
> handler's command object. Minimizing the amount of configuration and=20
> typing here would be really nice.
>=20
> Another suggestion would be to (optionally) wrap all usages of=20
> <spring:bind> in another tag that could reach somehow into=20
> the request=20
> or the handler and discover the commandName. Something like:
>=20
> <spring:bindFromCommand>
> <spring:bind path=3D"type">
> ...
> </spring:bind>
> </spring:bindFromCommand>
>=20
> Suggestions or comments?
>=20
> Thanks!
> Seth
>=20
>=20
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by: SourceForge.net Broadband=20
> Sign-up now for SourceForge Broadband and get the fastest=20
> 6.0/768 connection for only $19.95/mo for the first 3 months!=20
http://ads.osdn.com/?ad_id=3D2562&alloc_id=3D6184&op=3Dclick
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: Oliver H. <Ol...@ou...> - 2004-05-18 01:29:25
|
I've got no problem with that. It's certainly not the usual case for me to have multiple forms so 80% of the time I'd probably be using that no param default.=20 Seth Ladd wrote: > What do you think about having the default for setNestedPath=20 > look into=20 > the Model for the path value, if none is given? |
|
From: Oliver H. <Ol...@ou...> - 2004-05-19 03:27:06
|
Great! Thanks Seth.=20 > Seth Ladd wrote: >=20 > I have written some tag files (I love JSP 2.0 for tag files) that do=20 > what we're talking about here. They also provide a wrapper for=20 > <spring:bind> until the developers decide this is a useful feature to=20 > integrate into the main code. |
|
From: Seth L. <se...@eh...> - 2004-05-18 01:11:48
|
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> That would be perfect. I really only want to specify the bean name once. Ideally, it would still pick it up from the Model's Map by default, but I see your point why you would want to be able to specify it. What do you think about having the default for setNestedPath look into the Model for the path value, if none is given? Thanks! Seth |
|
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.
|