> -----Original Message-----
> From: jlm...@gmail.com  
> Sent: Saturday, May 28, 2011 22:49
> To: Struts Users Mailing List
> Subject: Re: Access to ActionContext.getContext().getName() using OGNL
> 
> The reason is that I have  JSP which contains a form that 
> it's used for the creation and modificatio of records. 
> Depending on the name of the action, it is a creation (in 
> which certains field should be modifiable) or a modification 
> (in which those certains fields should be radonly). I was 

In order to prevent business logic from the JSP, yous should create methods on
your action to return the answer to "that" question.

Ex:

Action
{
        private boolean createMode;
        public boolean isCreateMode(){return createMode;}

        public String execute()
        {
                ...
                createMode=true; // allow editable fields, as this is a creation
                ...
        }
}

Now in this formulation, you do not even need the ActionContext, it should make
your code cleaner. A nice side effect would be the OGNL would default to a not
true evaluation if called on an action which does not have the createMode
property, making your fields read only.

> hoping to be able to do that using Struts2 tags, that's why I 
> need to get the name of the action.
> Sent via BlackBerry from T-Mobile
> 
> -----Original Message-----
> From: "Jason Pyeron" <jpye...@pdinc.us>
> Date: Sat, 28 May 2011 22:39:08
> To: 'Struts Users Mailing List'<user@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
> Subject: RE: Access to ActionContext.getContext().getName() using OGNL
> 
> > -----Original Message-----
> > From: JOSE L MARTINEZ-AVIAL [mailto:jlm...@gmail.com]
> > Sent: Saturday, May 28, 2011 16:53
> > To: Struts Users Mailing List
> > Subject: Access to ActionContext.getContext().getName() using OGNL
> > 
> > Hi,
> >   I've been looking for a while, but haven't found anything, so I'm 
> > asking here. How can I get the name of the action from a 
> Struts2 Tag? 
> > IOW, I would like to do something like 
> > ActionContext.getContext().getName(), but using <s:property
> 
> Why (so I can help better)?
> 
> > value="name"/>.
> 
> While this is not an answer to your question, this may help 
> your (assumed) end goal.
> 
> In the latest revision or release <= 2.1.6 The <s:url /> will 
> create a link to the current action.
> 
> 
> > I haven't found any information on how to do that.
> > 
> 
> If all else fails, kake a getter in your action.


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.

 


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

Reply via email to