You need to instantiate your formBean before the interceptor stack
tries to set the parameters. Common points in your code where you can
accomplish that are: instantiating the object when declared as an
instance variable, inside a constructor of your action, or implement
the Preparable interface and create it inside the prepare() method.
2008/9/17 928572663 <[EMAIL PROTECTED]>:
> I tried both suggestions and neither worked.
>
> The first thing I tried was to implement the getter/setters and change the
> JSP as you suggested. When I did this I got the following:
>
> Caused by: ognl.OgnlException: formBean [java.lang.NullPointerException]
> at ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:935)
> at
> ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:53)
> at
> ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:121)
> at
> com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.getProperty(ObjectAccessor.java:17)
> at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1643)
> at
> com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.getProperty(CompoundRootAccessor.java:116)
> ... 145 more
>
> Then I tried adding the SessionAware interface. The SessionAware interface
> requires me to implement this function:
>
> public void setSession(Map<String, Object> session)
> {
> session.put("formBean", formBean);
> }
>
> however, when the interceptor calls setSession() my formBean object hasn't
> been initialized yet, because the displayForm() action function hasn't been
> called yet. This is the function that creates the pojo form bean.
>
>
>
>
> Gabriel Belingueres wrote:
>>
>> I've never used a form field name like "#session.formBean.firstName"
>> before, but if you refactor your code a little:
>>
>> Make your action implement SessionAware interface and put a formBean
>> getter/setter in your actions (or some superclass of your wizard
>> actions), which takes it from the session:
>> public FormBean getFormBean() {
>> return (FormBean) sessionMap.get("formBean");
>> }
>> public void setFormBean(FormBean f) {
>> sessionMap.put("formBean", f);
>> }
>>
>> then in your JSP page name your form fields like this:
>>
>> <s:textfield name="formBean.firstName" label="First Name" size="16" />
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]