You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by prathima <pr...@yahoo.co.in> on 2010/06/23 03:56:08 UTC

Problem accessing a field from an object which is placed in session using the key from property file

Hi,
We are migrating Struts 1.2 application to Struts2 and I am facing some issues.
 
I have all the constants defined in a file called SalesConstants.java. It has a constant which is SALES_MKT_CAT ="marketing". In the Action class, an object(marketingProduct) of type Product is placed in session with key as "marketing".
For example: session.put(SalesConstants.SALES_MKT_CAT,marketingProduct).
 
I have to check if marketingProduct is in session and if so if it has salesPrice = 100 where salesPrice is a field in marketingProduct object which is of type Product.
 
How can I check this in if tag?
I tried #session.%{SalesConstant.SALES_MKT_CAT}.salesPrice but it didnt work
I do not want to specify "marketing" directly which is the value of SalesConstant.SALES_MKT_CAT. 
Also, how can I check if "marketingProduct" is in session or not?
We are currently upgrading from Struts 1.2 to Struts2 and we are in tight schedule. I understand we do not have logic:present , logic:equal tags in Struts2 :(
I am new to Struts2, Please help. 
 
Thanks,
Prathima 


Re: Problem accessing a field from an object which is placed in session using the key from property file

Posted by Wes Wannemacher <we...@wantii.com>.
try something like this -

#session[@fully.qualified.SalesConstants@SALES_MKT_CAT].salesPrice

-Wes

On Tue, Jun 22, 2010 at 9:56 PM, prathima <pr...@yahoo.co.in> wrote:
> Hi,
> We are migrating Struts 1.2 application to Struts2 and I am facing some issues.
>
> I have all the constants defined in a file called SalesConstants.java. It has a constant which is SALES_MKT_CAT ="marketing". In the Action class, an object(marketingProduct) of type Product is placed in session with key as "marketing".
> For example: session.put(SalesConstants.SALES_MKT_CAT,marketingProduct).
>
> I have to check if marketingProduct is in session and if so if it has salesPrice = 100 where salesPrice is a field in marketingProduct object which is of type Product.
>
> How can I check this in if tag?
> I tried #session.%{SalesConstant.SALES_MKT_CAT}.salesPrice but it didnt work
> I do not want to specify "marketing" directly which is the value of SalesConstant.SALES_MKT_CAT.
> Also, how can I check if "marketingProduct" is in session or not?
> We are currently upgrading from Struts 1.2 to Struts2 and we are in tight schedule. I understand we do not have logic:present , logic:equal tags in Struts2 :(
> I am new to Struts2, Please help.
>
> Thanks,
> Prathima
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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