You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Leszek Gawron <ou...@wlkp.org> on 2003/11/24 16:51:33 UTC

woody read only fields

There seems to be a slight problem with woody if you want to work with a read
only field. You have some options:

1. use wd:output
The problem: cannot output field running if the parent is repeater and not
form. This syntax works for top level widget:

form.getWidget( "ouput_widget" ).setValue( "test value" );

but this works only for object of _Form_ type. getWidget() method cannot be
resolved for a widget so you cannot do:

var model = form.getModel();

model.output_widget = "test value";

2. use wd:field with wi:styling type="output"
You will get a value without form input control but after submission the
field's value will get reset (no appropriate parameter in request parameters)

The solution:

Introduce a new field styling : "read-only" that would render the field like
this:
<xsl:when test="wi:styling[@read-only='true']">
    <xsl:value-of select="wi:value"/>
    <input name="{@id}" id="{@id}" type="hidden" value="{wi:value}" title="{wi:hint}"/>
</xsl:when>

	ouzo
-- 
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/       ouzo@wlkp.org           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |


Re: woody read only fields

Posted by Bruno Dumon <br...@outerthought.org>.
On Mon, 2003-11-24 at 16:51, Leszek Gawron wrote:
> There seems to be a slight problem with woody if you want to work with a read
> only field. You have some options:
> 
> 1. use wd:output
> The problem: cannot output field running if the parent is repeater and not
> form. This syntax works for top level widget:
> 
> form.getWidget( "ouput_widget" ).setValue( "test value" );
> 
> but this works only for object of _Form_ type.

Why doesn't this work if the parent is a repeater? Should be something
like this:

form.getWidget("myrepeater").getRow(0).getWidget("ouput_widget").setValue("test value");

>  getWidget() method cannot be
> resolved for a widget so you cannot do:
> 
> var model = form.getModel();
> 
> model.output_widget = "test value";

that's because the javascript widget wrapper doesn't support output
widgets. A patch for this has been provided here:
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=106944852602669&w=2
but it's not applied yet.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org