Struts logic-el match problem

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

fynessAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
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
fynessAuthor Commented:
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
TimYatesCommented:
can you post the actual code?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

fynessAuthor Commented:
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
TimYatesCommented:
  <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
fynessAuthor Commented:
yes sorry its cStatus
0
TimYatesCommented:
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
TimYatesCommented:
Obviously,

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

should be

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

;)
0
fynessAuthor Commented:
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
TimYatesCommented:
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
fynessAuthor Commented:

yeah the values are all there, the i tried using equal and i just get empty tables
0
TimYatesCommented:
               <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
fynessAuthor Commented:
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
TimYatesCommented:
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
TimYatesCommented:
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
fynessAuthor Commented:
Still no joy, am just getting all values regardless of wheather there is a match or not
0
TimYatesCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fynessAuthor Commented:
thanks!
0
TimYatesCommented:
:-)  It worked! :-)

Cool!

Good luck with it all :-)

Tim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.