Thanks for the reply, Jeromy. That is exactly what has not been working.
Unfortunately, the s:property does not work either.

"dept" is a Department domain object, with two field, deptId: short; and
deptName: String. Both have getters and setters.

The DepartmentAction retrieves the dept object from DB, and has getters and
setters for the domain "dept" object in the action.

I tried:
<s:property value="dept.deptId" />
<s:property value="%{dept.deptId}" /> 
(as well as a bunch of other things which shouldn't work, and don't)

But this does not work, and I think it should, from what the documentation
says. I can see the Action and the "dept" object on the stack in the Eclipse
debugger. When I created a deptId var, and create a getter and setter for it
in the Action, and do this:
<s:property value="deptId" />

This works just fine, but I shouldn't have to break the domain object out in
the Action, right?

(I don't have a struts.properties file set up, 'cause the default as you
said is enabled.)

This is all fundamental to struts2, so I've got to be doing something
stupid, right?

thanks, shadman


Jeromy Evans - Blue Sky Minds wrote:
> 
> I'm not 100% sure of your intent as this line is a bit strange - trying 
> to set the deptId to the deptName
> 
>          <s:hidden name="dept.deptId" value="dept.deptName" />
> 
> but anyway, the documentation on the wiki around the expressions for 
> some tags is a bit confusing and I suspect the problem is that you need 
> "%{ }" to explicitly identify the OGNL expression for the 'value' 
> attributes of s:hidden and s:textfield (but NOT for the 'value' 
> attribute of s:property). 
> 
> ie.
> 
> <s:form action="save" validate="true" >
>    <table cellspacing="0" cellpadding="0" border="0">
>    <tr>
>       <td align="right">ID:</td>
>       <td>
>          <s:property value="dept.deptId" />
>          <s:hidden name="dept.deptId" value="%{dept.deptName}" />
>       </td>
>    </tr><tr>
>      <s:textfield name="dept.deptName" label="Dept Name"
> value="%{dept.deptName}" size="10" /> 
>    </tr>
>    </table>
>    </s:form>
> 
> I'm assuming your s:property is working.  Contrary to what's stated on 
> http://struts.apache.org/2.x/docs/tag-syntax.html, the 'value' attribute 
> is not parsed as an expression.  Having to include %{} is called "Alt 
> Syntax" and this mode is enabled by default.
> 
> This is an extract from default.properties:
> ### use alternative syntax that requires %{} in most places
> ### to evaluate expressions for String attributes for tags
> struts.tag.altSyntax=true
> 
> regards,
>  Jeromy Evans
> 
> shadman wrote:
>> So, if the action properties are pushed onto the stack via OGNL, then
>> what
>> from below would be preventing me from seeing the values that should be
>> there? Displaying a list worked just find, the Dept object seems to be
>> unavailable. I have getter and setter, according to documentation, I
>> shouldn't have to do anything else. According to examples, what I show
>> below
>> would seem to be correct. Appreciate the help.
>>
>> Thanks, shadman
>>
>>
>> shadman wrote:
>>   
>>> I can't seem to get values retrieved from the DB to populate on the
>>> form.
>>> The list jsp and retrieving from DB work great, but values don't seem to
>>> make it to the jsp. I pass the ID into the action method, retrieve the
>>> record, and want to display the results.
>>>
>>> struts.xml:
>>>    <action name="findDeptId" class="actions.DepartmentAction"
>>> method="findById">
>>>          <result name="input">jsps/errors.jsp</result>
>>>          <result name="success">jsps/edit_dept.jsp</result>
>>>          <interceptor-ref name="crudStack"/>
>>>    </action>
>>>
>>> DepartmentAction:
>>>     public String findById () throws Exception {
>>>             this.dept = getDaoManager().getDeptDao().findById(this.getId());
>>>             return SUCCESS;
>>>     }
>>>
>>> Method fills dept object. also, getDept() & setDept() in action.
>>>
>>> edit_dept.jsp:
>>>   <s:form action="save" validate="true" >
>>>    <table cellspacing="0" cellpadding="0" border="0">
>>>    <tr>
>>>       <td align="right">ID:</td>
>>>       <td>
>>>          <s:property value="dept.deptId" />
>>>          <s:hidden name="dept.deptId" value="dept.deptName" />
>>>       </td>
>>>    </tr><tr>
>>>      <s:textfield name="dept.deptName" label="Dept Name"
>>> value="dept.deptName" size="10" /> 
>>>    </tr>
>>>    </table>
>>>    </s:form>
>>>
>>> I have to be doing something simple wrong, I just don't see it.
>>> shadman
>>>
>>>     
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-S2--form-population-problem-tf3792422.html#a10742001
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to