Back Forum Reply New

Command is handled in strange way when using AbstractWizardFormController

quot;)));       }       if (page == 1) {//display search manager formAssignCommand command = (AssignCommand) getCommand(request);System.out.println(quot;EMPLOYEE CNUM: quot;        + command.getEmployee());data.put(quot;managersquot;, AltenateManagers.searchAlternateManagers(        command.getSearchName(), command.getSearchDepartement()));       }       if (page == 2) {//display search for manager results
       }       if (page == 3) {//confirm       }       return data;   }
   /*    * (non-Javadoc)    *     * @see org..web.servlet.mvc.AbstractWizardFormController#processCancel(javax.servlet.from.fromServletRequest,    *      javax.servlet.from.fromServletResponse, java.lang.Object,    *      org..validation.BindException)    */   protected ModelAndView processCancel(fromServletRequest arg0,fromServletResponse arg1, Object arg2, BindException arg3)throws Exception {       // TODO Auto-generated method stub       return new ModelAndView(quot;assignquot;);   }
   /*    * (non-Javadoc)    *     * @see org..web.servlet.mvc.AbstractWizardFormController#processFinish(javax.servlet.from.fromServletRequest,    *      javax.servlet.from.fromServletResponse, java.lang.Object,    *      org..validation.BindException)    */   protected ModelAndView processFinish(fromServletRequest arg0,fromServletResponse arg1, Object arg2, BindException arg3)throws Exception {       // TODO Auto-generated method stub       return null;   }
   private class PersonEditorSupport extends PropertyEditorSupport {       public String getAsText() {Object value = getValue();return value == null ? quot;quot; : ((Person) value).getCnum();       }
       public void setAsText(String string) throws IllegalArgumentException {try {    Person p = AltenateManagers.getPersonByCnum(string);    if (p == null) {        throw new IllegalArgumentException(                quot;Invalid id for Person: quot; + string);    }    setValue(p);} catch (NumberFormatException ex) {    throw new IllegalArgumentException(quot;Invalid id for Person: quot;            + string);}       }   }
}
and pages assign.jsp:

Code:
lt;%@ page language=quot;javaquot; contentType=quot;text/html; charset=UTF-8quot;%gt;
lt;%@ taglib prefix=quot;cquot; uri=quot;jstl/corequot;%gt;
lt;%@ taglib prefix=quot;logquot; uri=quot;taglibs/log-1.0quot; %gt;
lt;%@ taglib prefix=quot;springquot; uri=quot;/WEB-INF/spring.tldquot; %gt;

lt;c:import ucl=quot;include/header.jspquot; /gt;

lt;form method=quot;postquot;gt;
lt;input type=quot;hiddenquot; name=quot;_pagequot; value=quot;0quot;gt;
lt;table cellpadding=quot;3quot; cellspacing=quot;3quot; border=quot;1quot;gt;
lt;theadgt;
lt;trgt;
lt;td colspan=quot;2quot;gt;Name amp;amp; postionlt;/tdgt;
lt;tdgt;Employee informationlt;/tdgt;
lt;tdgt;Contact informationlt;/tdgt;
lt;/trgt;
lt;/theadgt;
lt;spring:bind path=quot;assign.employeequot;gt;
lt;span style=quot;errorquot;gt;lt;cut value=quot;${status.errorMessage}quot;/gt;lt;/spangt;
lt;c:forEach items=quot;${subordinates}quot; var=quot;personquot;gt;
lt;trgt;
lt;tdgt;lt;input type=quot;radioquot; name=quot;employeequot; value=quot;lt;cut value=quot;${person.cnum}quot;/gt;quot;gt;lt;/tdgt;
lt;tdgt;
lt;cut value=quot;${person.fullName}quot;/gt;lt;br /gt;
lt;cut value=quot;${person.jobRole}quot;/gt;
lt;/tdgt;
lt;tdgt;
lt;cut value=quot;${person.employeeType}quot;/gt;lt;br /gt;
lt;cut value=quot;${person.location}quot;/gt;
lt;/tdgt;
lt;tdgt;
lt;a hrcf=quot;mailto:lt;cut value=quot;${person.internetMail}quot;/gt;quot;gt;lt;cut value=quot;${person.internetMail}quot;/gt;lt;/agt;lt;br /gt;
lt;cut value=quot;${person.notesMail}quot;/gt;
lt;/tdgt;
lt;/trgt;
lt;/c:forEachgt;
lt;/spring:bindgt;
lt;/tablegt;

lt;input type=quot;submitquot; name=quot;_target1quot; value=quot;Continuequot;gt;
lt;/formgt;

lt;c:import ucl=quot;include/footer.jspquot; /gt;
this one works well - if it is submitted with chosen user, the second page is displayed

assign2.jsp:

Code:
lt;%@ page language=quot;javaquot; contentType=quot;text/html; charset=UTF-8quot;%gt;
lt;%@ taglib prefix=quot;cquot; uri=quot;jstl/corequot;%gt;
lt;%@ taglib prefix=quot;logquot; uri=quot;taglibs/log-1.0quot; %gt;
lt;%@ taglib prefix=quot;springquot; uri=quot;/WEB-INF/spring.tldquot; %gt;
lt;c:import ucl=quot;include/header.jspquot; /gt;
lt;br/gt;

lt;form method=quot;postquot;gt;
lt;input type=quot;hiddenquot; name=quot;_pagequot; value=quot;1quot;gt;

lt;spring:bind path=quot;assign.searchNamequot;gt;
Name: lt;input type=quot;textquot; name=quot;lt;cut value=quot;${status.expression}quot;/gt;quot; value=quot;lt;c:out value=quot;${status.value}quot;/gt;quot; /gt; lt;br/gt;
lt;span style=quot;errorquot;gt;lt;c:out value=quot;${status.errorMessage}quot;/gt;lt;/spangt;
lt;/spring:bindgt;

lt;spring:bind path=quot;assign.searchDepartementquot;gt;
Department: lt;input type=quot;textquot; name=quot;lt;c:out value=quot;${status.expression}quot;/gt;quot; value=quot;lt;c:out value=quot;${status.value}quot;/gt;quot; /gt; lt;br/gt;
lt;c:out value=quot;${status.errorMessage}quot;/gt;
lt;/spring:bindgt;

lt;input type=quot;submitquot; name=quot;_target2quot; value=quot;Continuequot;gt;
lt;/formgt;

lt;c:import ucl=quot;include/footer.jspquot; /gt;
this page act strangelly.
If i submit this one it goes back to page 0, if i reload it (F5 in opera/FF) it goes either to page 2 or shows my custom error!

Why it oges at first to the entry page?! After the browser visits the welcome page, it forgots the cnum from the initial visit of page 0.

Isn't the commnad object persisten when i'm going thru the form pages?!

Thanks for any help.

Here is the Person class:

Code:

public class Person implements Serializable {

// BP cn
private String fullName;
// BP callupname
private String callupName;
// BP jobresponsibilities
private String jobRole;
// BP employeeType - evaluate
private String employeeType;
// BP locationcity
private String location;
// BP mail
private String internetMail;
// BP notesmail
private String notesMail;
// BP ismanager
private boolean isManager;
// BP serialnumber
private String cnum;
// disable actions ~ pending changes
private boolean actionDisabled;
public Person() {
super();
}

public Person(String aFullName, String acallupName, String aJobRole, String anEmployeeType,
String aLocation, String anInternetMail, String aNotesMail,
boolean isManager, String cnum) {
this.fullName = aFullName;
this.callupName = acallupName;
this.jobRole = aJobRole;
this.employeeType = anEmployeeType;
this.location = aLocation;
this.internetMail = anInternetMail;
this.notesMail = aNotesMail;
this.isManager = isManager;
this.cnum = cnum;
this.actionDisabled = false;
}
public String getCallupName() {
return callupName;
}
public void setCallupName(String callupName) {
this.callupName = callupName;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getCnum() {
return cnum;
}
public void setCnum(String cnum) {
this.cnum = cnum;
}
public String getEmployeeType() {
return employeeType;
}
public void setEmployeeType(String employeeType) {
this.employeeType = employeeType;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getInternetMail() {
return internetMail;
}
public void setInternetMail(String internetMail) {
this.internetMail = internetMail;
}
public boolean isManager() {
return isManager;
}
public void setManager(boolean isManager) {
this.isManager = isManager;
}
public String getJobRole() {
return jobRole;
}
public void setJobRole(String jobRole) {
this.jobRole = jobRole;
}
public String getNotesMail() {
return notesMail;
}
public void setNotesMail(String notesMail) {
this.notesMail = notesMail;
}

public boolean isActionDisabled() {
return actionDisabled;
}
public void setActionDisabled(boolean disabled) {
this.actionDisabled = disabled;
}
}
and dummy manager class:

Code:

public class AltenateManagers {

/*** */
public AltenateManagers() {
super();
// TODO Auto-generated constructor stub
}

/*** Get person by username * * @param username = IBM intranet id = IBM internet mail* @return person details if exists, null otherwise */
public static Person getPersonByUsername(String username){
return BluePagesUtils.getPersonByIntranetId(username);
}
/*** Get person by cnum* * @param cnum* @return person details if exists, null otherwise */
public static Person getPersonByCnum(String cnum){
return BluePagesUtils.getPersonByCnum(cnum);
}/*** Get manager's direct subordinates * * @param aManager* @return employees list*/
public static Collection getSubordinates(Person aManager){
return BluePagesUtils.getSubordinates(aManager);
}/*** Search for manager by name (like in BP) and departmentcode (optional)* * @param name search string  * @param departmentCode department code * * @return managers list*/
public static Collection searchAlternateManagers(String name, String departmentCode) {
// mark pending changes for managers being currently accepted or to be removed
return BluePagesUtils.searchPerson(name, departmentCode, true);
}/*** Get alternate managers for employee  * * @param employee * @return alternate managers */
public static Collection getAlternateManagers(Person employee){
// mark pending changes for managers being currently accepted or to be removed
return SabaUtils.getAlternateManagers(employee);
}/*** Assign alternate managers to employee* * @param anEmployee* @param aManager*/
public static void assignAlternateManager(Person anEmployee, Person aManager) {
//postAssignmentNotification(Person anEmployee, Person aManager);
}/*** Accept alternate manager assignment* * @param anEmployee* @param code hashcode*/
public static void acceptAlternateManagerAssignment(String id, String code) {
//checkAssignmentHashCode()
//postAssignmentNotification(Person anEmployee, Person aManager);
}

/*** Reject alternate manager assignment* * @param anEmployee* @param code hashcode*/
public static void rejectAlternateManagerAssignment(String id, String code) {
//checkAssignmentHashCode()
//postAssignmentNotification(Person anEmployee, Person aManager);
}

/*** Remove alternate manager assignment* * @param anEmployee* @param aManager* @return true if sucessfully removed, false otherwise*/
public static boolean removeAlternateManagerAssignment(Person anEmployee, Person aManager){
return true;
}

/*** Publish the altered assignments**/
public static void publish(){
// collect data
// publish

}

}
¥
Back Forum Reply New