Search code examples
javajspstrutsnestedequals

Nested <nested:equal> and <nested:write> in combination


Basically, my question is simple but it requires someone that knows Struts 1.1 and is still alive.

What I try to build looks like this in Pseudo-Code:

IF element.method1 = true THEN
   IF element.method2 = true THEN
      COLOR.GREEN, PRINT element.prop1
   ELSE
      COLOR.RED, PRINT element.prop1
   END
ELSE
   COLOR.BLACK, PRINT element.prop1
END

The whole thing would happen inside a iteration. So here what is currently working but not yet the goal:

<nested:equal property="method1" value="true">
    <nested:write property="prop1" /> 
</nested:equal>

<nested:notEqual property="method1" value="true">
    <nested:write property="prop1" />
</nested:notEqual>

Now what really drives me crazy is that this works as well:

<nested:equal property="method1" value="true">
   <nested:equal property="method2" value="true">
   </nested:equal>                
</nested:equal>
                        
<nested:notEqual property="method1" value="true">
   <nested:write property="prop1" />
</nested:notEqual>

But whenever I insert something between the two inner nested:equal tags it wont compile.

So my final solution (see below) wont compile complaining "Missing Endtag for nested:write."

<nested:equal property="method1" value="true">

   <nested:equal property="method2" value="true">
           <nested:write property="element.prop1" />
   </nested:equal>   
                        
</nested:equal>
                        
<nested:notEqual property="method1" value="true">
    <nested:write property="element.prop1" />
</nested:notEqual>

After about 4 hours I still don't have a idea how I could manage this so any suggestions would be really appreciated and helps even 2 weeks after this post because my next step is to dig into Struts 1.1 Documentation.


Solution

  • While the solution of Roman C worked perfectly, I also managed to get it together with the nested-tags.

    I am unfortunately not allowed to post the original source, however this is what does & how it works right now:

    <nested:form action="/someReq" styleClass="standard">
        <nested:present property="myBean.genList">
    
            <nested:iterate property="myBean.genList" indexId="index">
    
                <nested:equal property="method1" value="true">
    
                    <nested:equal property="method2" value="true">
                        <strong class="green">
                            <nested:write property="prop1" />
                        </strong>
                    </nested:equal>
    
                    <nested:notEqual property="method2" value="true">
                        <strong class="red">
                            <nested:write property="prop1" />
                        </strong>
                    </nested:notEqual>
    
                </nested:equal>
    
                <nested:notEqual property="method1" value="true">
                    <nested:write property="prop1" />
                </nested:notEqual>
    
            </nested:iterate>
    
        </nested:present>
    </nested:form>