You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bill Lear <ra...@zopyra.com> on 2003/09/23 16:51:15 UTC

[OFF-TOPIC] OGNL question

The OGNL site appears to be down and I can't seem to be able to
contact Drew Davidson or the appropriate mailing list to ask an OGNL
question.  Since Tapestry makes extensive use of OGNL, perhaps this is
not too terribly off-topic.

I have a Map of Employee which contains a List of Address:

 class Address {
    String street; String city; String state; String zip;
 }

 class Employee {
    Integer employeeID;
    List addressList;
  }

  Map employees = new HashMap();

I would like to find employees who have an address that matches a
certain zip code pattern.  However, when I have the list of addresses,
I can't seem to figure out how to access the intermediate list, walk
it, and extract the employees that match:

  employeeByID.values.{?#this.addressList.zip.matches('787..')}

This gives "ognl.NoSuchPropertyException: zip".

If I have a "one-level" address in Employee:

 class Employee {
    Integer employeeID;
    Address address;
  }

I can construct the OGNL fairly easily:

  employees.values.{?#this.address.zip.matches('787..')}

If anyone could help, or suggest how I might get some help elsewhere
(OGNL mailing list?), I'd appreciate it.  I'm considering JXPath as an
alternative, and if anyone has thoughts on this to share that'd be
helpful, too.

Thanks.


Bill

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: [OFF-TOPIC] OGNL question

Posted by James Hays <ja...@mac.com>.
I think I follow what you are doing, so here is my initial thought.  
Move your logic out of OGNL and use a method in your page class.  From 
what I'm understanding, you want to get a list of addresses where the 
zip code matches your criteria.  You could create a method, which takes 
your arguments and returns a list:

public List getAddresses(String zip1, String zip2) // or a list of zips 
if you desire.
{
// logic to return addresses
return myList;
}

Then, point to this method using ognl for your component.  
...expression="getAddresses('12345', '78945')" />

Just a thought.

Bill Lear wrote:

>The OGNL site appears to be down and I can't seem to be able to
>contact Drew Davidson or the appropriate mailing list to ask an OGNL
>question.  Since Tapestry makes extensive use of OGNL, perhaps this is
>not too terribly off-topic.
>
>I have a Map of Employee which contains a List of Address:
>
> class Address {
>    String street; String city; String state; String zip;
> }
>
> class Employee {
>    Integer employeeID;
>    List addressList;
>  }
>
>  Map employees = new HashMap();
>
>I would like to find employees who have an address that matches a
>certain zip code pattern.  However, when I have the list of addresses,
>I can't seem to figure out how to access the intermediate list, walk
>it, and extract the employees that match:
>
>  employeeByID.values.{?#this.addressList.zip.matches('787..')}
>
>This gives "ognl.NoSuchPropertyException: zip".
>
>If I have a "one-level" address in Employee:
>
> class Employee {
>    Integer employeeID;
>    Address address;
>  }
>
>I can construct the OGNL fairly easily:
>
>  employees.values.{?#this.address.zip.matches('787..')}
>
>If anyone could help, or suggest how I might get some help elsewhere
>(OGNL mailing list?), I'd appreciate it.  I'm considering JXPath as an
>alternative, and if anyone has thoughts on this to share that'd be
>helpful, too.
>
>Thanks.
>
>
>Bill
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org