Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Struts logic-el match problem

Posted on 2004-10-22
19
Medium Priority
?
2,287 Views
Last Modified: 2013-11-24
Hi,

I'm having trouble creating a match in my jsp using struts. I have the following line within an two iterate tages

 <logic-el:match name="CCStatus" property="person.areaCode.areaCode" value="${AreaCode.areaCode}">            

The first iterate tag is
<logic:iterate id="AreaCode" name="areaCodes">

which just itereates through an arraylist containing AreaCode objects. (the AreaCode object has a String attribute, areaCode, which is what is been called in the value element above)

the second iterate tag is
<logic:iterate id="CCStatus" name="cStatus">
this arraylist contains objects of CCStatus which has a person object as an attribute. The person object then has a AreaCode object attribute, hence the person.areaCode.areaCode property.

Can anyone think of a reason why there is no match coming up? I've done tested such as
<bean:write name="CCStatus" property="person.areaCode.areaCode"/>
<bean:write name="AreaCode" property="areaCode"/>
and the values are printed out, so its not that the object are null.

Any help would be great,
Thanks

0
Comment
Question by:fyness
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
19 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 12379197
is

<logic:iterate id="AreaCode" name="areaCodes">
    <logic:iterate id="CCStatus" name="cStatus">
        <logic:equal name="CCStatus" property="person.areaCode.areaCode" value="AreaCode.areaCode">
           
        </logic:equal>
    </logic:iterate>
</logic:iterate>

any better?
0
 

Author Comment

by:fyness
ID: 12379217
Nope, still just shows all the values in all the area codes, i.e. theres no seperation for persons in a different area code
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12379226
can you post the actual code?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:fyness
ID: 12379244
Not really meant to post the code, but here is the basic jist of it
Thanks

   <logic:present name="CCStatus">
      <logic:iterate id="AreaCode" name="areaCodes">
                <table align="center" border="0" cellspacing="2" cellpadding="2" class="datatable">
                <tr>
                  <td colspan="5" align="center">
                    <h2>
                      <bean:write name="AreaCode" property="areaCode" />
                    </h2>                      
                  </td>                
                </tr>
                  <tr>
                    <td>
                      <h2>
                        <bean:message key="formdata.personname" />
                      </h2>
                    </td>
 </tr>
            <logic:iterate id="CCStatus" name="cStatus">
  <logic-el:match name="CCStatus" property="person.areaCode.areaCode" value="${AreaCode.areaCode}">               <tr>
                      <td class="SmallText">
                              <bean:write name="CCStatus" property="perosn.name"/>
                     </td>       
  </logic-el:match>                 
                  </logic:iterate>
                </table>
                </logic:iterate>
                </logic:present>      
               
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12379291
  <logic:present name="CCStatus">

is that meant to be:

   <logic:present name="cStatus">

?

As you have CCStatus defined twice by the looks of that...
0
 

Author Comment

by:fyness
ID: 12379293
yes sorry its cStatus
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12379361
Hmmm...I've never used the logic-el tags, but it looks like there is a logic-el:iterate tag...  Maybe you need to use this when you are using logic-el:match?

Can you try:

<logic:present name="cStatus">
    <logic-el:iterate id="AreaCode" name="areaCodes">
        <table align="center" border="0" cellspacing="2" cellpadding="2" class="datatable">
            <tr>
                <td colspan="5" align="center">
                    <h2>
                        <bean:write name="AreaCode" property="areaCode" />
                    </h2>                      
                </td>                
            </tr>
            <tr>
                <td>
                    <h2>
                        <bean:message key="formdata.personname" />
                    </h2>
                </td>
            </tr>
            <logic-el:iterate id="CCStatus" name="cStatus">
                <logic-el:match name="CCStatus" property="person.areaCode.areaCode" value="${AreaCode.areaCode}">            
                    <tr>
                        <td class="SmallText">
                            <bean:write name="CCStatus" property="perosn.name"/>
                        </td>      
                    </tr>
                </logic-el:match>                
            </logic-el:iterate>
        </table>
    </logic-el:iterate>
</logic:present>  
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12379363
Obviously,

                            <bean:write name="CCStatus" property="perosn.name"/>

should be

                            <bean:write name="CCStatus" property="person.name"/>

;)
0
 

Author Comment

by:fyness
ID: 12379382
the logic-el:iterate doesnt work, it cant find the session when i use it. I tried it without the el on the match so as logic:match and no joy.

Not sure what the difference is with the above?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12379427
It really is odd...

I assume:

            <logic:iterate id="CCStatus" name="cStatus">
                <% if( ((CStatusClass)CCStatus).getPerson().getAreaCode().getAreaCode().equals( ((AreaCodeClass)AreaCode).getAreaCode() ) )
                      { %>
                    <tr>
                        <td class="SmallText">
                            <bean:write name="CCStatus" property="perosn.name"/>
                        </td>      
                    </tr>
                <% } %>
            </logic:iterate>
 
works (if you replace CStatusClass and AreaCodeClass with the actual qualified classnames for those two)

As I said, though I never used logic:match before...always logic:equal

Tim
0
 

Author Comment

by:fyness
ID: 12379484

yeah the values are all there, the i tried using equal and i just get empty tables
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12379531
               <logic:equal name="CCStatus" property="person.areaCode.areaCode" value="<%= ((AreaCodeClass)AreaCode).getAreaCode() %>">            

May work...

What is:

person.areaCode.areaCode

and

AreaCode.areaCode?  Are they both Strings?  Or an object of some sort or other?
0
 

Author Comment

by:fyness
ID: 12380231
person is an object attribute of CCStatus, and within perosn there is an AreaCode object attribute. The areacode class then has a string attribut areaCode.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12380252
Cool, so it's two trings...

That's bizarre that it doesn't work right... :-/

Does that last logic:equal work (2 comments up from this one)?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12380291
Hang on...the bit on this page http://struts.apache.org/faqs/struts-el.html which says;

"The "logic:match" and "logic:notMatch" tags have an additional attribute named "expr", which can take any value, and will be used as the value to compare against, in addition to the choices of "cookie", "header", "name"/"property", and "parameter"."

has got me thinking....it's not:

                <logic-el:match name="CCStatus" property="person.areaCode.areaCode" expr="${AreaCode.areaCode}">            

(expr instead of value)
0
 

Author Comment

by:fyness
ID: 12380345
Still no joy, am just getting all values regardless of wheather there is a match or not
0
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 12380505
How's this:

<logic:present name="cStatus">
    <logic:iterate id="AreaCode" name="areaCodes">
        <bean:define id="code" name="AreaCode" property="areaCode" />
        <table align="center" border="0" cellspacing="2" cellpadding="2" class="datatable">
            <tr>
                <td colspan="5" align="center">
                    <h2>
                        <bean:write name="AreaCode" property="areaCode" />
                    </h2>                      
                </td>                
            </tr>
            <tr>
                <td>
                    <h2>
                        <bean:message key="formdata.personname" />
                    </h2>
                </td>
            </tr>
            <logic:iterate id="CCStatus" name="cStatus">
                <logic:equal name="CCStatus" property="person.areaCode.areaCode" value="<%= code %>">            
                    <tr>
                        <td class="SmallText">
                            <bean:write name="CCStatus" property="person.name"/>
                        </td>      
                    </tr>
                </logic:equal>                
            </logic:iterate>
        </table>
    </logic:iterate>
</logic:present>  

Notice the bean:define to define this current area code into the value "code", then the logic:equal with <%= code %> for the value...
0
 

Author Comment

by:fyness
ID: 12381589
thanks!
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12381626
:-)  It worked! :-)

Cool!

Good luck with it all :-)

Tim
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question