Sure, the old data persists until it is changed.
When you want a new user, you need to create it somewhere, eg:

>        public void userNewAction(IRequestCycle cycle) {
>
>               UserEdit nextPage = (UserEdit) cycle.getPage("UserEdit");
>               nextPage.setUserId(0);
-->             nextPage.setUser(new EfiUser()); // need to init this obj?
>               nextPage.setNewUser(true);
>               cycle.activate(nextPage);

Cheers,
Nick.


Nazmul Bhuiyan wrote:

After making the EfiUser persist in the UserEdit.page the edit works fine
but after editing one user if I want to add a new user then the page get
populated the previous user. I’m setting user to the EditUser page only in
edit action. But in new action I’m not setting any user but still it is
getting the previous user. Note I’m using same page for add and update.

There must be something that I’m doing wrong in pageBeginRender method.

please look at the following code below?

UserListActive page invoke the action below and set the user to the UserEdit
page accordingly:

       public void userNewAction(IRequestCycle cycle) {

              UserEdit nextPage = (UserEdit) cycle.getPage("UserEdit");
              nextPage.setUserId(0);
              nextPage.setNewUser(true);
              cycle.activate(nextPage);
       }

       public void userEditAction(IRequestCycle cycle) {
UserEdit nextPage = (UserEdit) cycle.getPage("UserEdit");
              Object[] parameters = cycle.getServiceParameters();
              int id = ((Integer) parameters[0]).intValue();

              EfiUser user = EfiUserDAO.getEfiUserById(id);
nextPage.setUser(user);
              nextPage.setNewUser(false);
              cycle.activate(nextPage);
       }



Page spec:

<property-specification name="user"
type="com.fujitsu.efi.infringement.model.EfiUser" persistent="yes"/>

UserEdit page:

       public void pageBeginRender(PageEvent event) {

              if (!getNewUser() && !event.getRequestCycle().isRewinding()) {
                     EfiUser user = getUser();
                     setActiveDate(getUser().getUsrActiveDate().getTime());

                     if (getUser().getUsrExpiryDate() != null) {
setExpiryDate(getUser().getUsrExpiryDate().getTime());
                     }

              } else {

                     userLoggedIn =
AuthorisationUtil.getNormalisedRemoteUserName(event);
                     if (getUser() == null) {
                           setUser(new EfiUser());
                     }
              }
       }

Thanks

Naz


Nick Westgate wrote:
How is the User object persisted?
(What relates to it in your UserEdit.page file?)

Cheers,
Nick.


Nazmul Bhuiyan wrote:
I’m loosing the User object as soon as the edit action is invoked?

I’m setting an object (e.g. User) in page UserMaint.java to the page
UserEdit.java.

UserMaint.java

public void userEditAction(IRequestCycle cycle) {
UserEdit nextPage = (UserEdit) cycle.getPage("UserEdit");
        Object[] parameters = cycle.getServiceParameters();
        int id = ((Integer) parameters[0]).intValue();

        EfiUser user = EfiUserDAO.getEfiUserById(id);
                
        nextPage.setUser(user);
        nextPage.setNewUser(false);
        cycle.activate(nextPage);
}

In pageBeginRender method of UserEdit shows the User object with all the
attributes:

UserEdit.java

public abstract void setUser(EfiUser user);
public abstract EfiUser getUser()

public void pageBeginRender(PageEvent event) {

  if (!getNewUser() && !event.getRequestCycle().isRewinding()) {
                        
System.out.println("Inside pageBeginRender..................");
System.out.println("user: " + getUser());
System.out.println("ID: " + getUser().getUsrUserId());
        .
        .
        etc
  }                     
}

>From Debug:
Inside pageBeginRender..................
user: [EMAIL PROTECTED]
ID: 1

But in the updateUser method the User object is different and the fields
I
don’t want to update are null.

UserEdit.java

public void updateUser(IRequestCycle cycle) {
        System.out.println("In updateUser");

        IValidationDelegate delegate = getValidationDelegate();

        //HibernateUtil.restartSession();

        System.out.println("Inside updateUser..................");
System.out.println("user: " + getUser());
System.out.println("ID: " + getUser().getUsrUserId());
        .
        .
        etc     
}

>From Debug:
Inside updateUser..................
user: [EMAIL PROTECTED]
ID: 0

Please help.

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





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

Reply via email to