Thanks, Craig.  For some reason I had the impression that you couldn't use
"<%= %>" tags inside of the Struts taglibs.  I'll try it out.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
rg]On Behalf Of Craig R. McClanahan
Sent: Sunday, August 05, 2001 4:41 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Martin Cooper
Subject: RE: Form processing question




On Sun, 5 Aug 2001, Greg Maletic wrote:

> That was my idea, too, but it doesn't seem to work.  I'm doing the
> following:
>
> <logic:present parameter="productId" %>
>       <html:form action="editProductConfirmed.do">
> </logic:present>
> <logic:notPresent parameter="productId" %>
>       <html:form action="addProductConfirmed.do">
> </logic:present>
>
>
> But the parser goes nuts with this.  XML doesn't allow improperly nested
> tags, so it complains that there's no matching </html:form> tag inside of
> the <logic:present> tag.
>
> Does anyone have any other ideas?

How about a runtime expression?  It's illustrated below with a scriptlet
for brevity, but you could also precompute the destination in an Action,
or as a property of your form bean:

  <%
    String destination = "editProductConfirmed.do";
    if (request.getParameter("productId" == null)
        destination = "addProductConfirmed.do";
  %>
  <html:form action="<%= destination %>">

In the Struts example app, you will find that I addressed this issue
differently -- the same Action is used for the "add", "edit", and
"delete" cases, and a hidden variable is included on the form to indicate
which transaction should be performed.  That way, you don't have to mess
around when designing the page.


>
> Thanks.
>

Craig

> -----Original Message-----
> From: Martin Cooper [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, August 04, 2001 11:27 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Form processing question
>
>
> One way to do this would be to use the Struts conditional tags to generate
a
> different URL on the page for edit versus add. You could base the decision
> on the presence or absence of your productId parameter.
>
> --
> Martin Cooper
>
>
> ----- Original Message -----
> From: "Greg Maletic" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 02, 2001 5:09 PM
> Subject: Form processing question
>
>
> > I have a JSP that is used to edit data on a ActionForm bean.  There are
> two
> > ways for users to reach this JSP:  1) if they're adding a new object
into
> my
> > app; 2) if they're editing an existing object in my app.  I'm using two
> > mappings in my struts-config.xml file to represent these two types of
> > actions ("/add" and "/edit"), although they both map to this same JSP.
> > (Additionally, the "/edit" mapping has a parameter called "productId"
that
> > describes which product to edit, while the "/add" mapping doesn't have a
> > parameter.)
> >
> > It's the behavior when the JSP's form is submitted that I'm having
trouble
> > with.  If the JSP was reached through the "add" mapping, I want it to go
> to
> > an "/addExecute" mapping that will actually add the object.  And if the
> JSP
> > was reached through the "edit" mapping, I want the form to go to an
> > "/editExecute" mapping that will actually make the modifications to the
> > object.  (As above, the "/editExecute" mapping needs a "productId"
> parameter
> > specified--passed through from the original "/edit" mapping--while the
> > "/addExecute" mapping doesn't.)  Unfortunately, I can't figure out how
to
> > conditionally make the form submit to one of two different actions
> > ("/addExecute" or "/editExecute").
> >
> > Is there a way to make this work?  Is this the right technique for
solving
> > this problem?  If not, could someone please let me know how this is
> > typically done?
> >
> > Thanks!
> >
> > Greg
> >
> >
>
>
>
>


Reply via email to