See my comments in-line. You've got the idea of what I want to do, Joe.

Joe Germuska wrote:

At 11:08 PM -0800 3/13/05, Nic Werner wrote:

Is what I am doing calling JSP pages directly? From my struts-config
below I show them being mapped to Actions.

My question was that I have to set the html:form action to be the
calling Action in order to populate it, but I want it to submit to a
different page, and if I follow the Apache struts example as below, it
doesn't follow correctly.


I think I'm missing something.  Your struts-config looks fine:

My struts-config:
<action path="/userEdit"
type="com.racquetclub.action.UserEditAction" name="user">
<forward name="display" path="/Users/UserEdit.jsp"/>
</action>
<action path="/userUpdate"
type="com.racquetclub.action.UserUpdateAction"
name="user">
<forward name="success" path="/Users/displayUsers.jsp"/>
</action>


So the user goes here:

yourserver/yourCtx/userEdit.do

your UserEditAction executes, and is given an instance of ActionForm based on the form-bean config with the ID "user". It prepopulates and delivers to the UserEdit.jsp page.

This page includes a form which looks like this:
<html:form action="/userUpdate">...</html:form>

If I set the html:form to be "userUpdate", I get a blank form back, not prepopulated. That was my catch, setting it to 'userEdit' gets the right info in the form, but I need that data to go over to 'userUpdate'.

Isn't this the model? Action A populates Bean, JSP displays it, and JSP submits to Action B for processing.

When the <html:form> tag executes, it uses "/userUpdate" to look up an action mapping, where it finds that it needs an ActionForm linked to the id "user" for prepopulating its fields. It should find the same one which was prepopulated, and the fields should be filled according to what UserEditAction set up.

This is where I must be doing something wrong, my UserUpdateAction isn't finding the pre-populated form. Here is my code for both:


UserEditAction:
SqlMapClient sqlMap = DatabaseManager.getInstance();
//ActionForm userForm = (ActionForm) form;
try{
UserBean userForm = (UserBean)form;
UserBean user;
user = (UserBean)sqlMap.queryForObject("selectUser",userForm.getUserId());
BeanUtils.copyProperties(userForm,user);
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException("Error initializing MyAppSQLConfig class. Cause: " + e);
} return (mapping.findForward("display"));
-------------
UserUpdateAction
SqlMapClient sqlMap = DatabaseManager.getInstance();
UserBean userForm = (UserBean)form;
UserBean user;
try{
sqlMap.update("updateUser",userForm);
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException("Error initializing MyAppSQLConfig class. Cause: " + e);
} return (mapping.findForward("success"));



When the form submits, it is processed by a different action at a different path linked to the same form-bean ("user"). You might want to add "validate='true'" to the "/userUpdate" mapping, unless you're not performing any validation with Struts.


What isn't working? It sounds like you think your form has to submit to "/userEdit", but it doesn't, if you have another action mapping which uses the same ("user") form bean.

Joe



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



Reply via email to