1) Again, replace the names of your form fields: from: to: 2) SessionAware interface: it is pointless to implement it if you are not going to save the session Map in an instance variable for future reference, and if getting the session through Map session = (Map)ActionContext.getContext().get("session"); works, it is not the preferred way of getting it [1] 3) javascript code: Note that if the user press Enter key on a textfield, the form will be submitted without assigning your target hidden field. [1] http://struts.apache.org/2.1.2/docs/how-do-we-get-access-to-the-session.html 2008/9/19 Dave Newton : > As was mentioned to you previously, at the very least you shouldn't use "#session..." as the name; you should just use "session" if you've implemented a getSession() method. That may be enough; can't test at the moment. > > Dave > > --- On Fri, 9/19/08, 928572663 <928572663@cox.net> wrote: >> I am using Zero Configuration (annotations), so no >> struts.xml necessary. >> >> ---------------- >> formDetails.jsp >> ---------------- >> >> > Strict//EN" >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >> >> <%@ page contentType="text/html;charset=UTF-8" >> language="java"%> >> <%@ taglib prefix="s" >> uri="/struts-tags"%> >> >> >> >> IPSM struts2 Demo Form >> > rel="stylesheet" >> type="text/css" /> >> >> >>

>> >>

>> >> >> > method="post"> >> >> > name="#session.formBean.requery" >> label="Requery?" /> >> >> > name="#session.formBean.firstName" >> value="%{#session.formBean.firstName}" >> label="First Name" >> size="16" /> >> >> > name="#session.formBean.maxValue" >> value="%{#session.formBean.maxValue}" >> label="Max Value" >> size="10" /> (> value="%{#session.formBean.maxValueRangeMin}" >> />-> value="%{#session.formBean.maxValueRangeMax}" >> />) >> >> > name="#session.formBean.lastName" >> value="%{#session.formBean.lastName}" >> label="Last Night" >> size="10" required="true" /> >> >> > key="#session.formBean.maxValueRangeMax" >> label="Max Routes (Max)" /> >> >> > name="#session.formBean.comment" >> cols="15" rows="8" /> >> >> > name="#session.formBean.selection" >> value="%{#session.formBean.selection}" >> label="Selection" >> list="#session.formBean.picklist" >> listKey="code" >> listValue="label" /> >> >> > value="setme" /> >> >> > value="/images/back_button.gif" /> >> > src="%{#back_button_url}" label="" >> cssClass="formButton" >> onclick="javascript:this.form.target.value='backButton'; >> >> this.form.submit();" /> >> >> > value="/images/next_button.gif" /> >> > src="%{#next_button_url}" label="" >> cssClass="formButton" >> onclick="javascript:this.form.target.value='nextButton'; >> >> this.form.submit();" /> >> >> >> >> >> >> >> ---------------- >> MyFormBean.jsp >> ---------------- >> >> package sample; >> >> import java.util.ArrayList; >> import java.util.List; >> >> public class MyFormBean >> { >> private boolean requery = true; >> private String firstName = ""; >> private String selection = ""; >> private String lastName = ""; >> private String comment = ""; >> private int maxValue = 0; >> >> //~~~ items for GUI display purposes etc. >> private final int maxValueRangeMin = 1; >> private final int maxValueRangeMax = 263732; >> private List picklist = null; >> //~~~ >> >> public MyFormBean() >> { >> picklist = new ArrayList(); >> picklist.add(new >> PicklistItem("1","Item 1")); >> picklist.add(new >> PicklistItem("2","Item 2")); >> picklist.add(new >> PicklistItem("3","Item 3")); >> picklist.add(new >> PicklistItem("4","Item 4")); >> picklist.add(new >> PicklistItem("5","Item 5")); >> } >> >> public boolean isRequery() >> { >> return requery; >> } >> >> public void setRequery(boolean requery) >> { >> this.requery = requery; >> } >> >> public String getFirstName() >> { >> return firstName; >> } >> >> public void setFirstName(String firstName) >> { >> this.firstName = firstName; >> } >> >> public String getSelection() >> { >> return selection; >> } >> >> public void setSelection(String selection) >> { >> this.selection = selection; >> } >> >> public String getLastName() >> { >> return lastName; >> } >> >> public void setLastName(String lastName) >> { >> this.lastName = lastName; >> } >> >> public String getComment() >> { >> return comment; >> } >> >> public void setComment(String comment) >> { >> this.comment = comment; >> } >> >> public int getMaxValue() >> { >> return maxValue; >> } >> >> public void setMaxValue(int maxValue) >> { >> this.maxValue = maxValue; >> } >> >> public List getPicklist() >> { >> return picklist; >> } >> >> public void setPicklist(List >> picklist) >> { >> this.picklist = picklist; >> } >> >> public int getMaxValueRangeMin() >> { >> return maxValueRangeMin; >> } >> >> public int getMaxValueRangeMax() >> { >> return maxValueRangeMax; >> } >> } >> >> ---------------- >> PicklistItem.jsp >> ---------------- >> >> package sample; >> >> >> public class PicklistItem >> { >> private String code = ""; >> private String label = ""; >> >> public PicklistItem(String aCode, String aLabel) >> { >> code = aCode; >> label = aLabel; >> } >> >> public String getCode() >> { >> return code; >> } >> >> public void setCode(String code) >> { >> this.code = code; >> } >> >> public String getLabel() >> { >> return label; >> } >> >> public void setLabel(String label) >> { >> this.label = label; >> } >> } >> >> ---------------- >> SampleAction.jsp >> ---------------- >> >> package sample; >> >> >> import java.util.Map; >> >> import org.apache.struts2.config.Result; >> import org.apache.struts2.config.Results; >> import org.apache.struts2.interceptor.SessionAware; >> import org.apache.struts2.views.tiles.TilesResult; >> >> >> import com.opensymphony.xwork2.ActionContext; >> import com.opensymphony.xwork2.ActionSupport; >> >> @Results( >> { >> @Result(name = "displayFormPage", value = >> "/formDetails.jsp"), >> @Result(name = "homeError", value = >> "/homeError.page", type = >> TilesResult.class) >> } ) >> public class SampleAction extends ActionSupport implements >> SessionAware >> { >> private String message = ""; >> private String target = ""; >> private MyFormBean formBean = new MyFormBean(); >> >> public void setSession(Map >> session) >> { >> Object obj = session.get("formBean"); >> if (obj == null) >> { >> session.put("formBean", formBean); >> } >> } >> >> public void setFormBean(MyFormBean formBean) >> { >> Map session = >> (Map)ActionContext.getContext().get("session"); >> session.put("formBean", formBean); >> } >> >> public MyFormBean getFormBean() >> { >> Map session = >> (Map)ActionContext.getContext().get("session"); >> return >> (MyFormBean)session.get("formBean"); >> } >> >> public String displayForm() throws Exception >> { >> formBean = new MyFormBean(); >> formBean.setComment("struts2 is cool"); >> formBean.setFirstName("Linus"); >> formBean.setLastName("Torvalds"); >> formBean.setMaxValue(50); >> >> setFormBean(formBean); >> >> // Map session = (Map) >> ActionContext.getContext().get("session"); >> // session.put("formBean",formBean); >> >> return "displayFormPage"; >> } >> >> public String submit() throws Exception >> { >> if (target != null >> && target.length() > 0) >> { >> setMessage(target >> + " was pressed."); >> } >> >> // Map session = (Map) >> ActionContext.getContext().get("session"); >> // formBean = >> (MyFormBean)session.get("formBean"); >> >> return "displayFormPage"; >> } >> >> public String getMessage() >> { >> return message; >> } >> >> public void setMessage(String message) >> { >> this.message = message; >> } >> >> public String getTarget() >> { >> return target; >> } >> >> public void setTarget(String target) >> { >> this.target = target; >> } >> } >> >> >> >> >> Gabriel Belingueres wrote: >> > Could you post your struts.xml, action and (one of >> the) JSP? >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> For additional commands, e-mail: >> user-help@struts.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org