cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Sylvain.The...@swisscom.com>
Subject RE: [XMLForm] Found my problem - Howto resolve this in general? (BUG)
Date Thu, 13 Feb 2003 08:52:40 GMT
Hi Jakob,

I have the same "unrolling" problem as you with a "repeat" tag.

Could you send me your new version of XMLTransformer, so I could test it.


Thanks
Sylvain (T)


-----Message d'origine-----
De: Jakob Praher [mailto:jpraher@yahoo.de]
Date: mercredi, 12. février 2003 21:37
À: cocoon-dev@xml.apache.org
Objet: [XMLForm] Found my problem - Howto resolve this in general? (BUG)


hi all, 

did some hard core research, and found the following bug in the
XMLFormTransformer.java:

the "unrolling" of the "recorded" tags like "itemset" and "repeat" is
only done if: 

class XMLFormTransformer .... {
...
Object _value ;
...

...
void unrollItemSetTag( DocumentFragment aFragment ) {
...
while ( ... )
..
	if ( _value != null ) {
		/* do the stream of the fragment */
	}
}
...
...

now it comes:
_value is set by Form.getValue( xpath ), which is the @ref Attribute of
according the xmlform element.

I think the _value null-checking is done in order to test that a valid
form control was found before, but _value gets also null if there is a
correct field in the object but the bean property is not initialized for
instance String or List, like that:

class Bean {

	Map    allLangues = ... 
	String language;

	public Set allLanguages( ) {
		return allLanguages.entrySet( );
	}
	public String getLanguage( ) { ... }
	public void setLanguage( String value ) { ... }
} 


now given this example, if you to the following control:

<xf:selectOne ref="language" >
  <xf:itemset nodeset="/allLanguages">
    <xf:caption ref="value" />
    <xf:value ref="key" />
  </xf:itemset>
</xf:selectOne>

this will never display an initialized listbox, as:

inside XMLFormTransformer:

_value = Form.getValue( "language" );

will be null, when the form is in the start phase.

so I propose changing the _value checking to a boolean state variable.

like:
boolean haveRefBoundElement = false;

and after doing:
in "startELementSimpleFIeld( ... ) "
value_ = form.getValue( ref )
haveRefBoundElement = true;

and then change the streaming part of the 

void unrollItemSetTag( DocumentFragment docFragment ) 
....
while ( ... ) {
..
if ( haveRefBoundElement )
{
  // stream back the recorder repeat content
  DOMStreamer streamer = new DOMStreamer( this, this);
  streamer.stream( docFragment );
}
..
}


-- Jakob


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


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


Mime
View raw message