cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Ekstedt <ekst...@ibg.uu.se>
Subject XMLForm and flow, beans only show up after reload
Date Thu, 17 Apr 2003 09:37:57 GMT
Hello

I'm having a bit of trouble with XMLForm and Flow. I've got two sorts of
beans (generated from a hibernate hbm.xml file) called Taxon and
Specifier. A taxon owns one or more specifiers. This is my flowscript:


=================== registration.js =============================
cocoon.load("resource://org/apache/cocoon/components/flow/javascript/xmlForm.js");

function registerTaxon(xform) {

  var taxonBean = new Packages.se.uu.ebc.beans.Taxon();
  var specifierBean1 = new Packages.se.uu.ebc.beans.Specifier();
  var specifierBean2 = new Packages.se.uu.ebc.beans.Specifier();

  /* Initialize specifier 1 */
  specifierBean1.setId(1);

  /* Initialize specifier 2 */
  specifierBean2.setId(2);

  /* Add specifier1 and 2 to the taxonBean */
  var specifiers = new java.util.HashSet();
  specifiers.add(specifierBean1);
  specifiers.add(specifierBean2);
  taxonBean.setSpecifiers(specifiers);

  xform.setModel(taxonBean);

  /* start form handling */
  xform.sendView("name", "forms/name.xml");
  xform.sendView("definition", "forms/definition.xml");
  xform.sendView("specifiers", "forms/specifiers.xml");
  xform.sendView("submitter", "forms/submitter.xml");
  xform.sendView("confirm", "forms/confirm.xml");

  /* save the beans */
  var mapper =
cocoon.componentManager.lookup(Packages.se.uu.ebc.components.ORMapper.ROLE);
  try {

    /* get hibernate session */
    var hibSession = mapper.openSession();

    hibSession.save(taxonBean);
    hibSession.flush();
    hibSession.close();
    hibSession = null;

  } finally {
    cocoon.componentManager.release(mapper);
  }


  xform.finish("forms/end.xml");
}
============================================================


forms/specifiers.xml is the form showing the specifiers of a taxon and
contains the snippet:


========= forms/specifiers.xml =============================

    ...
    <xf:repeat nodeset="specifiers">
      <xf:textbox ref="id">
	<xf:caption>Specifier id</xf:caption>
      </xf:textbox>
    </xf:repeat>
    ...
============================================================

Moving through the forms works as expected up until specifiers.xml. The
first time it is visited the xf:repeat is transformed into 

------------------------------------
<xf:repeat nodeset="specifiers">
  <xf:group ref="/specifiers[1]"/>
  <xf:group ref="/specifiers[2]"/>
</xf:repeat>
------------------------------------
with error.log showing 

... XMLFormTransformer: pass through element [group]

Now if I press Back, going back to forms/definition.xml and then forward
again I get the correct behaviour in the specifier form. The
transformation returns:

------------------------------------
   <xf:repeat nodeset="specifiers">

    <xf:group ref="/specifiers[1]">
      <xf:textbox ref="/specifiers[1]/id">
	<xf:value>1</xf:value>
	<xf:caption>Specifier id</xf:caption>
      </xf:textbox>
    </xf:group>

    <xf:group ref="/specifiers[2]">
      <xf:textbox ref="/specifiers[2]/id">
	<xf:value>2</xf:value>
	<xf:caption>Specifier id</xf:caption>
      </xf:textbox>
    </xf:group>

  </xf:repeat>
------------------------------------

which is what I wanted. Anyone who can shed some light on this? 

// Jonas


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message