Hi Sergio, add SessionAware interface to your action. Best greetings, Pawel Wielgus.
2010/1/5, Sergio <killing-is-my-busin...@hotmail.com>: > Sergio escribió: >> Hi people, >> >> i'm a newbie to struts2. I'm having too many problems modifing session >> parameters. I use <%= session.getAttribute( "variable" ) %> to gain >> access to "variable" and that works when i modify "variable" into a >> jsp page, but not inside a struts action. >> >> struts.xml: >> >> <?xml version="1.0" encoding="UTF-8" ?> >> <!DOCTYPE struts PUBLIC >> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" >> "http://struts.apache.org/dtds/struts-2.0.dtd"> >> >> <struts> >> >> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> >> <constant name="struts.devMode" value="true" /> >> >> <package name="tads" namespace="/" extends="struts-default"> >> >> <action name="HolaMundo" class="tads.HolaMundo"> >> <result>/holaMundo.jsp</result> >> </action> >> >> <action name="Catalogo" class="tads.Catalogo"> >> <result name="error">/ErrorCatalogo.jsp</result> >> <result>/Catalogo.jsp</result> >> </action> >> >> <action name="Actualiza" class="tads.Actualiza"> >> <result>/Actualiza.jsp</result> >> </action> >> >> >> >> </package> >> >> </struts> >> >> extract from a jsp page, result from an ajax action working: >> >> <s:form id="form" > >> <s:textfield name="politico" label="politico"/><br> >> <s:hidden name="prueba" value="escondido" /> >> </s:form> >> <s:url id="actualiza" value="/Actualiza.action" /> >> >> <sx:submit type="button" label="dale" href="%{actualiza}" >> formId="form" align="center" targets="secondaryContent"/> >> >> i see "politico" and "prueba" into Actualiza.action so the action >> Actualiza works. >> >> Actualiza.java: >> >> package tads; >> import java.util.*; >> >> import javax.servlet.http.HttpSession; >> import com.opensymphony.xwork2.ActionSupport; >> import org.apache.struts2.interceptor.SessionAware; >> import com.opensymphony.xwork2.ActionContext; >> >> >> @SuppressWarnings("serial") >> public class Actualiza extends ActionSupport implements SessionAware { >> private String politico; >> private String prueba; >> private Map session; >> public String execute() throws Exception { >> >> this.getSession().put("variable","pruebamil"); >> return SUCCESS; >> } >> public String getPolitico() { >> return politico; >> } >> >> public void setPolitico(String politico) { >> this.politico = politico; >> } >> >> public String getPrueba() { >> return prueba; >> } >> >> public void setPrueba(String prueba) { >> this.prueba = prueba; >> } >> public void setSession(Map session) { >> this.session = session; >> } >> public Map getSession() { >> return session; >> } >> } >> >> in that situation. Actualiza.jsp doesn't show "variable" atribute from >> session, using "<%= session.getAttribute( "variable" ) %>". It shows >> null. >> >> can anybody help me? I'm doing exactly what struts2 FAQ say (How do we >> get access to the session). >> >> thanks in advance. >> > i've tried with > > <%= session.getAttribute( "variable" ) %> > > and > > <s:property value="#session.variable"></s:property> > > and surprise, both works. After closing and opening eclipse 3.4.0 works. > I think this is a bad memory managing of eclipse. Does anybody knows > something about this? > > -- > Sergio > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org