You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kyle Robinson <KR...@pangaeainc.com> on 2001/03/15 19:27:29 UTC

logic:equal and nesting

Here's a piece of code that I want to do.  However it gives a nested tag
error as the closing </logic:equal> tag ends up inside the <html:form>. I
basically want the form to do different actions based on the property
"title".  Anyone know of a better way of doing the same thing?
 
<logic:equal name="supplierSearchBean" property="title"
            scope="request" value="Contractor">
  <html:form action="contractorSearch.do">
</logic:equal>
<logic:equal name="supplierSearchBean" property="title"
            scope="request" value="Supplier">
  <html:form action="supplierSearch.do">
</logic:equal>


Kyle Robinson 
Systems Consultant 
Pangaea Systems Inc. 
(250) 360-0111 

 

Re: logic:equal and nesting

Posted by Maya Muchnik <mm...@pumatech.com>.
Do you need or not to have a statement </html:form> ?

Kyle Robinson wrote:

>  Here's a piece of code that I want to do.  However it gives a nested
> tag error as the closing </logic:equal> tag ends up inside the
> <html:form>. I basically want the form to do different actions based
> on the property "title".  Anyone know of a better way of doing the
> same thing?<logic:equal name="supplierSearchBean" property="title"
>             scope="request" value="Contractor">
>   <html:form action="contractorSearch.do">
> </logic:equal>
> <logic:equal name="supplierSearchBean" property="title"
>             scope="request" value="Supplier">
>   <html:form action="supplierSearch.do">
> </logic:equal>
> Kyle Robinson
> Systems Consultant
> Pangaea Systems Inc.
> (250) 360-0111

Re: logic:equal and nesting

Posted by John Raley <jo...@moonlight.com>.
I run into this kind of thing a lot.  It's a constant reminder that the
tag syntax is not a substitute for the control structures we're used to
in programming languages...

It's ugly, but I would probably handle this with scripting vars:
<% String theAction = null; %>
<logic:equal name="supplierSearchBean" property="title"
            scope="request" value="Contractor"><%
theAction="contractorSearch.do"; %>
</logic:equal>
<logic:equal name="supplierSearchBean" property="title"
            scope="request" value="Supplier"><%
theAction="contractorSearch.do"; %>
</logic:equal>
  <html:form action="<%= theAction %>">


Kyle Robinson wrote:

>  Here's a piece of code that I want to do.  However it gives a nested
> tag error as the closing </logic:equal> tag ends up inside the
> <html:form>. I basically want the form to do different actions based
> on the property "title".  Anyone know of a better way of doing the
> same thing?<logic:equal name="supplierSearchBean" property="title"
>             scope="request" value="Contractor">
>   <html:form action="contractorSearch.do">
> </logic:equal>
> <logic:equal name="supplierSearchBean" property="title"
>             scope="request" value="Supplier">
>   <html:form action="supplierSearch.do">
> </logic:equal>
> Kyle Robinson
> Systems Consultant
> Pangaea Systems Inc.
> (250) 360-0111


Re: logic:equal and nesting

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 15 Mar 2001, Kyle Robinson wrote:

> Here's a piece of code that I want to do.  However it gives a nested tag
> error as the closing </logic:equal> tag ends up inside the <html:form>. I
> basically want the form to do different actions based on the property
> "title".  Anyone know of a better way of doing the same thing?
>  
> <logic:equal name="supplierSearchBean" property="title"
>             scope="request" value="Contractor">
>   <html:form action="contractorSearch.do">
> </logic:equal>
> <logic:equal name="supplierSearchBean" property="title"
>             scope="request" value="Supplier">
>   <html:form action="supplierSearch.do">
> </logic:equal>
> 

As the error message tells you, this is invalid nesting of tags.  In order
to change the destination of the submit, you will need to create some
JavaScript that does so on the client side, perhaps when the submit button
is presed.  (If you do this, be sure you use the same form bean on all of
the actions, or Struts is likely to get confused.)

Alternatively, you could have the <html:form> tag submit to a single
action, (say, "/commonSearch.do") which could then look at the title
property itself and then forward to either "/contractorSearch.do" or
"/supplierSearch.do" appropriately.

> 
> Kyle Robinson 
> Systems Consultant 
> Pangaea Systems Inc. 
> (250) 360-0111 
> 
>  
> 
Craig