You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Hutchinson <be...@gmail.com> on 2005/08/24 15:44:27 UTC

DynaForms and EL (dynabean.map not working)

Hi there. 

I have a form that uses org.apache.struts.validator.LazyValidatorForm.

When I pre-populate this form before displaying it, I use code like
the following in the action:

final DynaBean dynaForm = (DynaBean)form;
dynaForm.set("displayName", "test");

In my JSP, I have a <html:text> element that looks like this:

<html:text property="displayName" size="25" />

The value 'test' is populated as expected.

Now I want to change this from a <html:text> to just hard output (via
<c:out>) if some boolean is true:

    <c:choose>
      <c:when test="${param.function == 'displayEdit'}">
         <html:text property="displayName" size="25" />
      </c:when>
      <c:otherwise>
         <c:out value="${dynabean.map.displayName} />
      </c:otherwise>
    </c:choose>

I can't seem to get the <c:out> to render anything using the
dynabean.map.prop value as described in the guide. What am I doing
wrong?

I'm using Struts 1.2.7 on Tomcat 5.5 with JSTL 1.1.2
My includes are:
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

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


Re: DynaForms and EL (dynabean.map not working)

Posted by Hubert Rabago <hr...@gmail.com>.
What name did you use to pass this form from action to jsp?

Hubert

On 8/24/05, John Hutchinson <be...@gmail.com> wrote:
> Hi there.
> 
> I have a form that uses org.apache.struts.validator.LazyValidatorForm.
> 
> When I pre-populate this form before displaying it, I use code like
> the following in the action:
> 
> final DynaBean dynaForm = (DynaBean)form;
> dynaForm.set("displayName", "test");
> 
> In my JSP, I have a <html:text> element that looks like this:
> 
> <html:text property="displayName" size="25" />
> 
> The value 'test' is populated as expected.
> 
> Now I want to change this from a <html:text> to just hard output (via
> <c:out>) if some boolean is true:
> 
>     <c:choose>
>       <c:when test="${param.function == 'displayEdit'}">
>          <html:text property="displayName" size="25" />
>       </c:when>
>       <c:otherwise>
>          <c:out value="${dynabean.map.displayName} />
>       </c:otherwise>
>     </c:choose>
> 
> I can't seem to get the <c:out> to render anything using the
> dynabean.map.prop value as described in the guide. What am I doing
> wrong?
> 
> I'm using Struts 1.2.7 on Tomcat 5.5 with JSTL 1.1.2
> My includes are:
> <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
>

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


Re: DynaForms and EL (dynabean.map not working)

Posted by John Hutchinson <be...@gmail.com>.
Figured it out. 

dynabean.map.prop

should be 

<dynabean>.map.<prop>

Where <dynabean> is the name of your form from struts-config.

You can't actually use 'dynabean'. 


On 8/24/05, John Hutchinson <be...@gmail.com> wrote:
> I was under the impression that the form bean itself is a 'gimmie' and
> does not explicitly need to be set in the request scope (or any other
> scope for that matter).
> 
> For example, the
> <html:text property="displayName" size="25" />
> tag works without needing the 'name' property, so somehow the
> <html:text> tag knows to look in the form bean in this case. I could
> do something like you mention, but this page seems to indicate that I
> can use ${dynabean.map.prop}
> 
> http://struts.apache.org/userGuide/building_controller.html#dyna_action_form_classes
> 
> I even changed it back to org.apache.struts.action.DynaActionForm just
> to make sure it's not a LazyValidatorForm issue, but I still got
> nothing. Both implement org.apache.commons.beanutils.DynaBean so it
> should work in both cases (I think).
> 
> On 8/24/05, Hubert Rabago <hr...@gmail.com> wrote:
> > You should try using the name you're using for the form when you pass
> > it from your action to your JSP.
> >
> > > final DynaBean dynaForm = (DynaBean)form;
> > > dynaForm.set("displayName", "test");
> >
> > If you're using request.setAttribute("displayForm", dynaForm); then try
> >
> > <c:out value="${displayForm.map.displayName} />
> >
> > Hubert
> >
> > On 8/24/05, John Hutchinson <be...@gmail.com> wrote:
> > > Hi there.
> > >
> > > I have a form that uses org.apache.struts.validator.LazyValidatorForm.
> > >
> > > When I pre-populate this form before displaying it, I use code like
> > > the following in the action:
> > >
> > > final DynaBean dynaForm = (DynaBean)form;
> > > dynaForm.set("displayName", "test");
> > >
> > > In my JSP, I have a <html:text> element that looks like this:
> > >
> > > <html:text property="displayName" size="25" />
> > >
> > > The value 'test' is populated as expected.
> > >
> > > Now I want to change this from a <html:text> to just hard output (via
> > > <c:out>) if some boolean is true:
> > >
> > >     <c:choose>
> > >       <c:when test="${param.function == 'displayEdit'}">
> > >          <html:text property="displayName" size="25" />
> > >       </c:when>
> > >       <c:otherwise>
> > >          <c:out value="${dynabean.map.displayName} />
> > >       </c:otherwise>
> > >     </c:choose>
> > >
> > > I can't seem to get the <c:out> to render anything using the
> > > dynabean.map.prop value as described in the guide. What am I doing
> > > wrong?
> > >
> > > I'm using Struts 1.2.7 on Tomcat 5.5 with JSTL 1.1.2
> > > My includes are:
> > > <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
> > > <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

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


Re: DynaForms and EL (dynabean.map not working)

Posted by John Hutchinson <be...@gmail.com>.
I was under the impression that the form bean itself is a 'gimmie' and
does not explicitly need to be set in the request scope (or any other
scope for that matter).

For example, the 
<html:text property="displayName" size="25" />
tag works without needing the 'name' property, so somehow the
<html:text> tag knows to look in the form bean in this case. I could
do something like you mention, but this page seems to indicate that I
can use ${dynabean.map.prop}

http://struts.apache.org/userGuide/building_controller.html#dyna_action_form_classes

I even changed it back to org.apache.struts.action.DynaActionForm just
to make sure it's not a LazyValidatorForm issue, but I still got
nothing. Both implement org.apache.commons.beanutils.DynaBean so it
should work in both cases (I think).

On 8/24/05, Hubert Rabago <hr...@gmail.com> wrote:
> You should try using the name you're using for the form when you pass
> it from your action to your JSP.
> 
> > final DynaBean dynaForm = (DynaBean)form;
> > dynaForm.set("displayName", "test");
> 
> If you're using request.setAttribute("displayForm", dynaForm); then try
> 
> <c:out value="${displayForm.map.displayName} />
> 
> Hubert
> 
> On 8/24/05, John Hutchinson <be...@gmail.com> wrote:
> > Hi there.
> >
> > I have a form that uses org.apache.struts.validator.LazyValidatorForm.
> >
> > When I pre-populate this form before displaying it, I use code like
> > the following in the action:
> >
> > final DynaBean dynaForm = (DynaBean)form;
> > dynaForm.set("displayName", "test");
> >
> > In my JSP, I have a <html:text> element that looks like this:
> >
> > <html:text property="displayName" size="25" />
> >
> > The value 'test' is populated as expected.
> >
> > Now I want to change this from a <html:text> to just hard output (via
> > <c:out>) if some boolean is true:
> >
> >     <c:choose>
> >       <c:when test="${param.function == 'displayEdit'}">
> >          <html:text property="displayName" size="25" />
> >       </c:when>
> >       <c:otherwise>
> >          <c:out value="${dynabean.map.displayName} />
> >       </c:otherwise>
> >     </c:choose>
> >
> > I can't seem to get the <c:out> to render anything using the
> > dynabean.map.prop value as described in the guide. What am I doing
> > wrong?
> >
> > I'm using Struts 1.2.7 on Tomcat 5.5 with JSTL 1.1.2
> > My includes are:
> > <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
> > <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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


Re: DynaForms and EL (dynabean.map not working)

Posted by Hubert Rabago <hr...@gmail.com>.
You should try using the name you're using for the form when you pass
it from your action to your JSP.

> final DynaBean dynaForm = (DynaBean)form;
> dynaForm.set("displayName", "test");

If you're using request.setAttribute("displayForm", dynaForm); then try

<c:out value="${displayForm.map.displayName} />

Hubert

On 8/24/05, John Hutchinson <be...@gmail.com> wrote:
> Hi there.
> 
> I have a form that uses org.apache.struts.validator.LazyValidatorForm.
> 
> When I pre-populate this form before displaying it, I use code like
> the following in the action:
> 
> final DynaBean dynaForm = (DynaBean)form;
> dynaForm.set("displayName", "test");
> 
> In my JSP, I have a <html:text> element that looks like this:
> 
> <html:text property="displayName" size="25" />
> 
> The value 'test' is populated as expected.
> 
> Now I want to change this from a <html:text> to just hard output (via
> <c:out>) if some boolean is true:
> 
>     <c:choose>
>       <c:when test="${param.function == 'displayEdit'}">
>          <html:text property="displayName" size="25" />
>       </c:when>
>       <c:otherwise>
>          <c:out value="${dynabean.map.displayName} />
>       </c:otherwise>
>     </c:choose>
> 
> I can't seem to get the <c:out> to render anything using the
> dynabean.map.prop value as described in the guide. What am I doing
> wrong?
> 
> I'm using Struts 1.2.7 on Tomcat 5.5 with JSTL 1.1.2
> My includes are:
> <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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