You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John Studarus <st...@jhlconsulting.com> on 2004/02/15 20:59:34 UTC

persistence null values after form submit


  I am having issues clearing out a persistent property
on a page during the rewind process of a form.
  ActionLink passes as a parameter the id of the object to edit
to another page.  The object is then stored (fireObservedChange)
in the new page as a persistent property and edited/canceled/deleted 
by the user.  At the conclusion I want to clear out the
persistent property so the next use of the page will load
the object from the passed parameters.
  Unfortunately I get a null pointer error when I try
to get the object to null when the submit/cancel/delete button
in pressed.  Where should I null out the object for the subsequent 
use of this page?  I take it I am getting this because I am
setting it to null during a rewind operation?
  If I don't set the object to null and call fireObservedChange
I'll get the object persisting from the previous page load.
  The alternate is to pass the object via a Visit but I
am trying to move away from passing parameters from Page to
Page via the Visit object.  But that is starting to get
cumbersome and the Visit object just keeps growing with
each new page.
  Appropriate bits and pieces of code are enclosed.  Any ideas?

  Thanks,

        John 
  



  <component id="cancel" type="Submit">
    <binding name="listener" expression="listeners.cancelSubmit"/>
  </component>

  private Nameserver _nameserver = null ;

  public void cancelSubmit(IRequestCycle cycle)
  {
    setNameserver(null) ;       //  <- this is causing the exception
    cycle.activate("UpdateAssessment");
    System.out.println("end of cancelSubmit") ;
  }
  public void setNameserver(Nameserver nameserver) {
    _nameserver = nameserver ;    
    fireObservedChange("nameserver", nameserver) ;
  }
  public void detach() {
    _nameserver = null ;
    super.detach() ;
  }
  public void initialize() {
    _nameserver = null ;
  }

  //   the params are passed via an ActiveLink from another page
  public Nameserver getNameserver() {
    if ( null == _nameserver ) {
      Object[] objects = getRequestCycle().getServiceParameters() ;
      if ( objects!=null && objects.length>=1 ) {
        // Hibernate code to load object cut
        setNameserver((Nameserver) sess.load(Nameserver.class, id)) ;
        // initial code loads object from params OK
      } 
    }
    return _nameserver ;
  }

org.apache.tapestry.ApplicationRuntimeException: Unable to invoke method cancelSubmit on redspin.tapestry.page.NameserverPage@1b45ddc[NameserverDetails]: null
        at org.apache.tapestry.listener.ListenerMap.invokeTargetMethod(ListenerMap.java:327)
        at org.apache.tapestry.listener.ListenerMap.access$100(ListenerMap.java:87)
        at org.apache.tapestry.listener.ListenerMap$SyntheticListener.invoke(ListenerMap.java:141)
        at org.apache.tapestry.listener.ListenerMap$SyntheticListener.actionTriggered(ListenerMap.java:146)
        at org.apache.tapestry.form.Submit.renderComponent(Submit.java:121)
        at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:896)
        at org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:673)
        at org.apache.tapestry.form.Form.renderComponent(Form.java:394)
        at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:896)
        at org.apache.tapestry.form.Form.rewind(Form.java:598)
        at org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:475)



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org