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]