You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Rob Oxspring <ro...@imapmail.org> on 2007/04/27 18:11:30 UTC
null-text on text fields?
Hi,
I need to present a form where a text box displays something rather than
nothing when the associated value is empty, for example see the
behaviour of the search input at http://java.sun.com/. This seems to be
much like the selection-list's null-text facility which obviously isn't
available on normal text fields. I was wondering whether anyone could
point me to any existing examples and/or advice on how to achieve this
affect within the cforms framework?
An avenue I was looking into was to implement a converter to special
case the empty value but since I'm dealing with strings I'm put off by
the converter documentation saying "Strings obviously don't support any
convertors, since there's no purpose in converting a string to a
string". I've also tried building javascript event handlers and
validators but managed to get myself in an infinite loop using the
following:
<fd:on-value-changed>
<fd:javascript>
<![CDATA[
if(this.value=='' || this.value==null) {
this.value = this.fieldDefinition.initialValue;
}
print('CHANGE ' + this.value);
]]>
</fd:javascript>
</fd:on-value-changed>
<fd:validation>
<fd:javascript>
<![CDATA[
if(this.value==this.fieldDefinition.initialValue) {
this.value = null;
}
print('VALIDATE ' + this.value);
return true;
]]>
</fd:javascript>
</fd:validation>
Any thoughts and advice welcome :)
Thanks in advance,
Rob
Rob Oxspring
roxspring@imapmail.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: null-text on text fields?
Posted by Joerg Heinicke <jo...@gmx.de>.
On 27.04.2007 18:11, Rob Oxspring wrote:
> I need to present a form where a text box displays something rather than
> nothing when the associated value is empty, for example see the
> behaviour of the search input at http://java.sun.com/. This seems to be
> much like the selection-list's null-text facility which obviously isn't
> available on normal text fields. I was wondering whether anyone could
> point me to any existing examples and/or advice on how to achieve this
> affect within the cforms framework?
What about doing this only as presentation concern, i.e. handling this
for example in the stylesheet?
> An avenue I was looking into was to implement a converter to special
> case the empty value but since I'm dealing with strings I'm put off by
> the converter documentation saying "Strings obviously don't support any
> convertors, since there's no purpose in converting a string to a
> string".
So you see the comment is not quite true :)
> I've also tried building javascript event handlers and
> validators but managed to get myself in an infinite loop using the
> following:
That's obvious. You change the value and this leads again to
on-value-changed.
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org