You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Felipe Rodrigues <fe...@yahoo.com.br> on 2007/04/05 19:34:31 UTC

How to get a attribute value of map value?

Hi guys,

I have this case now, and I'm not getting take the value of a map value
attribute.
Let me explain better. I have a class:

class Mov{   private String att;   public String getAtt(){  return att; } }

and I put it inside a java.util.Map, like

Map test = new HashMap();
test.put("AnyString", new Mov( ) );

So I'm trying to get the value of att from the map, using OGNL.
%{test['AnyString']} prints the mov.toString( ), 
%{test['AnyString'].att} prints nothing and finally
%{test['AnyString']}.att prints it as literal.

Using EL I would do that, ${test['AnyString'].att}, how could I do the same
thing using OGNL?

Thanks in advance,

Felipe
-- 
View this message in context: http://www.nabble.com/How-to-get-a-attribute-value-of-map-value--tf3532725.html#a9859811
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to get a attribute value of map value?

Posted by Felipe Rodrigues <fe...@yahoo.com.br>.
Yeah, I know.

I'll make some others test. I just aked to make discart a OGNL syntax error.
So if it is the correct form, so I need figure out what value is getting to
att.

And yes, My class has the setAtt method. Actually, this value comes from
database using boxSQL framework. (http://boxsql.dev.java.net)

Anyway, Thanks for your help.


cilquirm wrote:
> 
> 
> The second way, %{test['AnyString'].att} or even, explicitly,
> %{test['AnyString'].getAtt()} should both work.
> 
> I know it might sound dumb, but is there a value to att? ( using that
> class as an example, there's no way to set it :-)
> 
> -a
> 
> 
> Felipe Rodrigues wrote:
>> 
>> Hi guys,
>> 
>> I have this case now, and I'm not getting take the value of a map value
>> attribute.
>> Let me explain better. I have a class:
>> 
>> class Mov{   private String att;   public String getAtt(){  return att; }
>> }
>> 
>> and I put it inside a java.util.Map, like
>> 
>> Map test = new HashMap();
>> test.put("AnyString", new Mov( ) );
>> 
>> So I'm trying to get the value of att from the map, using OGNL.
>> %{test['AnyString']} prints the mov.toString( ), 
>> %{test['AnyString'].att} prints nothing and finally
>> %{test['AnyString']}.att prints it as literal.
>> 
>> Using EL I would do that, ${test['AnyString'].att}, how could I do the
>> same thing using OGNL?
>> 
>> Thanks in advance,
>> 
>> Felipe
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-get-a-attribute-value-of-map-value--tf3532725.html#a9867545
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to get a attribute value of map value?

Posted by cilquirm <aa...@gmail.com>.

The second way, %{test['AnyString'].att} or even, explicitly,
%{test['AnyString'].getAtt()} should both work.

I know it might sound dumb, but is there a value to att? ( using that class
as an example, there's no way to set it :-)

-a


Felipe Rodrigues wrote:
> 
> Hi guys,
> 
> I have this case now, and I'm not getting take the value of a map value
> attribute.
> Let me explain better. I have a class:
> 
> class Mov{   private String att;   public String getAtt(){  return att; }
> }
> 
> and I put it inside a java.util.Map, like
> 
> Map test = new HashMap();
> test.put("AnyString", new Mov( ) );
> 
> So I'm trying to get the value of att from the map, using OGNL.
> %{test['AnyString']} prints the mov.toString( ), 
> %{test['AnyString'].att} prints nothing and finally
> %{test['AnyString']}.att prints it as literal.
> 
> Using EL I would do that, ${test['AnyString'].att}, how could I do the
> same thing using OGNL?
> 
> Thanks in advance,
> 
> Felipe
> 

-- 
View this message in context: http://www.nabble.com/How-to-get-a-attribute-value-of-map-value--tf3532725.html#a9860232
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to get a attribute value of map value?

Posted by Felipe Rodrigues <fe...@yahoo.com.br>.
So, in the link you sent me, I found this: 
myEntitiesMap['%{id}'].value
It is used to change the value of some Entitie inside the Map.
How to put some entitie inside the Map using OGNL?

One more question.Where could I found out when to use %{} or #?

Thanks,

Felipe


Mark Menard wrote:
> 
> On 4/5/07 1:34 PM, "Felipe Rodrigues" <fe...@yahoo.com.br> wrote:
> 
>> %{test['AnyString'].att} prints nothing and finally
> 
> I've used this technique to access the properties of entities stored in a
> Map. (http://www.vitarara.org/cms/node/81) Are you sure that the "att"
> attribute has something in it?
> 
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-get-a-attribute-value-of-map-value--tf3532725.html#a9867609
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to get a attribute value of map value?

Posted by Felipe Rodrigues <fe...@yahoo.com.br>.
hum... I thought it could be the right way, because print nothing is better
than print it as a literal.
I'll debug a little more to find the error.
Thanks anyway.



Mark Menard wrote:
> 
> On 4/5/07 1:34 PM, "Felipe Rodrigues" <fe...@yahoo.com.br> wrote:
> 
>> %{test['AnyString'].att} prints nothing and finally
> 
> I've used this technique to access the properties of entities stored in a
> Map. (http://www.vitarara.org/cms/node/81) Are you sure that the "att"
> attribute has something in it?
> 
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-get-a-attribute-value-of-map-value--tf3532725.html#a9867565
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to get a attribute value of map value?

Posted by Mark Menard <ma...@mjm.net>.
On 4/5/07 1:34 PM, "Felipe Rodrigues" <fe...@yahoo.com.br> wrote:

> %{test['AnyString'].att} prints nothing and finally

I've used this technique to access the properties of entities stored in a
Map. (http://www.vitarara.org/cms/node/81) Are you sure that the "att"
attribute has something in it?

Mark

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