Since our TabSetControl should switch between the tabs on the client-side, i.e.
without the server, all the data must be loaded at the beginning. We use a
Formbean for handing over to the JSP-Page. It provides the various tabs access
to the display data.
import java.io.IOException;
import javax.servlet.ServletException;
import com.cc.framework.adapter.struts.ActionContext;
import com.cc.framework.adapter.struts.FWAction;
import com.cc.framework.adapter.struts.FormActionContext;
import com.cc.sampleapp.common.Messages;
import com.cc.sampleapp.common.User;
import com.cc.sampleapp.tabset.sample402.form.UserProfileEditForm;
public class UserProfileEditAction extends FWAction {
/**
* @see com.cc.framework.adapter.struts.FWAction#doExecute(ActionContext)
*/
public void doExecute(ActionContext ctx)
throws IOException, ServletException {
try {
// Generate a Default User for our Example
User user = new User("FAS");
user.load();
initFormBean(ctx, user);
}
catch (Throwable t) {
ctx.addGlobalError("Error while loading User Object", t);
log.error("Error: ", t);
}
// Display the JSP
ctx.forwardToInput();
}
/**
* Initializ the Form with the User-Data
* @param ctx ActionContext
* @param user User-Object
* @exception java.lang.Exception
*/
private void initFormBean(ActionContext ctx, User user)
throws Exception {
UserProfileEditForm form = (UserProfileEditForm) ctx.form();
form.setUserId( user.getUserId());
form.setFirstName( user.getFirstName() );
form.setLastName( user.getLastName() );
form.setRole( user.getRole() );
form.setGuitype( user.getSettings().getGuitype() );
form.setDefprinter( user.getSettings().getDefprinter() );
}
}
back |
continue to step 4
|