cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <dho...@csir.co.za>
Subject Re: CForms - different views of the same widget
Date Fri, 04 Nov 2005 09:14:48 GMT
Thanks guys, what you say makes sense... but my "widget"
grammer is a little limited still; would the syntax be something 
like:
 
<fd:field id="key" required="true">
 <fd:on-value-changed>
  <javascript>
   var thisWidget = event.source.lookupWidget("key");
   if ( thisWidget.value() == "" ) {
     thisWidget.setState ( WidgetState.ACTIVE)
   }  else  {
    thisWidget.setState ( WidgetState.OUTPUT)
   }
  </javascript>
 </fd:on-value-changed>
</fd:field>

or, if not, then what (the above does not actually work;
seems thisWidget is null... but I am sure there are other
errors too...)?

Thanks
Derek

>>> sylvain@apache.org 2005/11/03 06:26:04 PM >>>
Jason Johnston wrote:
> Derek Hohls wrote:
> > Is it possible to set up the binding and display for a widget so that
> > it is styled differently depending on whether or not a value was set
> > for it *prior* to displaying the form?
> >
> > I would like to use this approach for a field containing a database
> > field index value - if its blank when the form is displayed, the user
> > must be able to fill it in (and *must* in fact fill it in);
>
> This just means that every field in the form is required="true", right?
>
> > but if a value
> > already exists, then the field should be displayed in "read only"
> > only mode; preferably just as a text string, [in worse case, it
> > would also be OK if the field was not displayed at all, but perhaps
> > still present in the form as a hidden field).
>
> You should be able to do this by extending the XSL that transforms the 
> field instances to HTML. Something like add an xsl:template that 
> matches fi:field[string-length(fi:value &gt; 0)] which then outputs 
> the value as text.
>
> Another possibility might be to add an fd:on-value-changed handler to 
> the fields that changes the widget state to OUTPUT when the value is 
> not empty.

That's exactly what I was about to propose: changing the widget's state 
on value change is what you're looking for!

Sylvain

-- 
Sylvain Wallez Anyware Technologies
http://people.apache.org/~sylvain http://www.anyware-tech.com 
Apache Software Foundation Member Research & Technology Director


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




-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
HelpDesk@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


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


Mime
View raw message