Thanks for the reply, Dave. So I have the following:
struts2test1.xml
<action name="findDeptId"
class="com.att.etpi.eval.struts2.actions.DepartmentAction">
<result name="input">jsps/edit_list.jsp</result>
<result name="success">jsps/edit_dept.jsp</result>
<interceptor-ref name="crudStack"/>
</action>
Java:
public class Department implements java.io.Serializable {
private short deptId;
private String deptName;
public Department() { }
public short getDeptId() { return this.deptId; }
public void setDeptId(short deptId) { this.deptId = deptId; }
public String getDeptName() { return this.deptName; }
public void setDeptName(String deptName) { this.deptName = deptName;}
}
public class DepartmentAction extends ActionSupport
implements Preparable,
ParameterAware
{
public String execute () throws Exception {
this.dept = getDaoManager().getDeptDao().findById(this.getId());
return SUCCESS;
}
private Department getDept() { return dept; }
private void setDept(Department department) { this.dept = department; }
}
edit_dept.jsp:
<s:form action="save" validate="true" namespace="/struts2test1" >
<table>
<tr>
<td align="right"> ID: </td>
<td>
<s:property value="dept.deptId" />/3:
</td>
</tr><tr>
<s:textfield name="dept.deptName" label="Dept Name"
value="dept.deptName" size="10" />
</tr>
</table>
</s:form>
For textfield:
<s:textfield name="deptName" label="Dept Name" value="dept.deptName" />
HTML produced is:
<td class="tdLabel"><label for="save_deptName" class="label">Dept
Name:</label></td>
<td><input type="text" name="deptName" value="dept.deptName"
id="save_deptName"/>
</td>
For textfield:
<s:textfield name="dept.deptName" label="Dept Name" value="dept.deptName" />
Produces:
<td class="tdLabel"><label for="save_dept_deptName" class="label">Dept
Name:</label></td>
<td><input type="text" name="dept.deptName" value="dept.deptName"
id="save_dept_deptName"/>
</td>
None of this works, unless I break the domain object out in the action. Is
the id="save_dept_deptName" correct? Can you see anything that I'm doing
wrong?
thanks once again for your time and help,
shadman
Dave Newton-4 wrote:
>
> --- shadman <[EMAIL PROTECTED]> wrote:
>> The DepartmentAction retrieves the dept object from
>> DB, and has getters and setters for the domain
> "dept"
>> object in the action.
>>
>> <s:property value="dept.deptId" />
>
> This is the proper syntax; I do it all over the place.
>
> If the action has a getDept() and the dept has a
> getDeptId(), and you are dispatching to the result
> (not redirecting), then it should work as you have it.
>
> I'd first re-check the flow to the result JSP, then
> check to make sure the objects are following JavaBean
> conventions...
>
> In short, all the stuff you've probably already done
> ;)
>
> But I'd do it again anyway :/
>
> d.
>
>
>
>
> ____________________________________________________________________________________Looking
> for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
> http://farechase.yahoo.com/
>
> ---------------------------------------------------------------------
> 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#a10745388
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]