cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject Re: disabling widgets
Date Wed, 25 Feb 2004 21:31:25 GMT
snip

 > > >>> I have a booleanfield widget, that needs to be disabled
>>  > >> under certain
>>  > >>> conditions.
>>  > >>>
>>  > >>> pseudo-code :
>>  > >>>
>>  > >>>    if ( album.scenarios.size() > 0 ) {
>>  > >>>        disable ( album.publishable );
>>  > >>>    }

I have solved this in a slightly hacky way ....

woody-model:
	. . .
  <wd:booleanfield id="publishable">
     <wd:label><i18n:text 
i18n:catalogue="local">label.publishable</i18n:text></wd:label>
     <wd:hint><i18n:text 
i18n:catalogue="local">hint.publishable</i18n:text></wd:hint>
  </wd:booleanfield>

  <wd:output id="scenariocount">
     <wd:label><i18n:text 
i18n:catalogue="local">label.scenarios</i18n:text></wd:label>
     <wd:hint><i18n:text 
i18n:catalogue="local">hint.scenarios</i18n:text></wd:hint>
     <wd:datatype base="string"/>
  </wd:output>
	. . .

woody-binding:
	. . .
   <wb:value id="publishable" path="publishable"/>
   <wb:value id="scenariocount" path="string(count(scenarios))" 
direction="load"/>
	. . .

woody-template:

   <wt:widget id="publishable"><wi:styling type="conditional" 
on="scenariocount"/></wt:widget>
   <wt:widget id="scenariocount"/>


XSLT:


<!-- conditional boolean field : checkbox and label in seperate cells 
-->
<xsl:template match="wi:booleanfield[wi:styling/@type='conditional']" 
mode="group-columns-content">
   <xsl:variable name="condition" select="wi:styling/@on"/>
   <tr>
     <td><xsl:apply-templates select="." mode="label"/></td>
     <td>
       <input id="{@id}" type="checkbox" value="true" name="{@id}" 
title="{wi:hint}">
         <xsl:if test="../wi:*[@id=$condition]/wi:value != '0' "> <!-- 
Yucky XPath !! -->
           <xsl:attribute 
name="onclick">this.checked=this.defaultChecked;alert('This Album is 
featured in a Scenario, it cannot be made Private 
anymore.');</xsl:attribute>
         </xsl:if>
         <xsl:apply-templates select="." mode="styling"/>
         <xsl:if test="wi:value = 'true'">
           <xsl:attribute name="checked">checked</xsl:attribute>
         </xsl:if>
       </input>
       <xsl:apply-templates select="." mode="common"/>
     </td>
   </tr>
</xsl:template>

It works for now ..... but is very application specific, and I would 
not want to do anything more complicated using this technique.

Thanks

regards Jeremy
Mime
View raw message