File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes How to refer dynamically object fields by using EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to refer dynamically object fields by using EL" Watch "How to refer dynamically object fields by using EL" New topic
Author

How to refer dynamically object fields by using EL

deepan thiagu
Greenhorn

Joined: May 15, 2007
Posts: 18
Hai everyone i need to display the Object field value by using Expression Language.
But i need to refer this Object field name dynamically by using Expression Language.
Here i don't how to use the nested Expression Language

Here my sample code is

#{fields} gives the field name of object �sample�

then how to i display �sample� field value

i try following ways

1)#{sample}.#{fields}
2) #{sample[fields]}

Please any one help me

By
Thiagu.m
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

Although EL can be tricky, I think in this case you're making it too hard. If you have a dictionary object ("d") and you want to access member "m" of that dictionary, I think the EL is simply "{d.m}". EL is done at run-time, and it's fairly dynamic.

Try it and see. For a fixed field, try "{d['m']}".


Customer surveys are for companies who didn't pay proper attention to begin with.
 
jQuery in Action, 2nd edition
 
subject: How to refer dynamically object fields by using EL