You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Carlos Chvez <cc...@agssa.net> on 2007/12/30 07:39:59 UTC

Re: [Forms] Bug in Ajax when changing widget state?

>> Hi people,

>> still trying to push CForms to its limits ;) I found what might be a
>> bug in the Ajax implementations. I have an event handler that switches
> the state of a widget from ACTIVE to INVISIBLE and vice-versa. When not
> using Ajax, everything works fine, but when ajax="true" the widget
> appears and disappears as expected, but its label stays forever hidden!

> Two points to note here:

> 1. the widget state is initially INVISIBLE
> 2. the widget is laid out in a group using <fi:styling type="colums"/>

> Can anyone else confirm this?

> 	Ugo

-- 
> Ugo Cei
> Tech Blog: http://agylen.com/
> Open Source Zone: http://oszone.org/
> Wine & Food Blog: http://www.divinocibo.it/

Hi People,

I found the message above that it's an old message, but that still being an
issue on CForms.

I found that the label field is not visible again because we only sent the
<bu:replace> <span id="..."> ...</span> </bu:replace> for the input field
but for the label we don't have anything similar.

When we show the form that initially have a field invisible and the field
it's on a <fi:group> ... we sent a placeholder for the field and this
generate this:

<label class="forms placeholder" id="field2:label" for="field2:input"
title=""/>

and

<span id="field2"/>

for example for a field "field2" (that is because the XSLT, now we only
generate the SAX's event only for the input, the label tag is generate
because the XSLT)

Now, when we got visible the field, the <bu:replace> <span id="..."> it's
just only for the field, we don't manage in anyway the label tag.

This is similar if the field it's initially visible, when we got invisible
the input field is gone, but the label still there because we don't manage
the label on the ajax update.

This is similar too when we use the <widget-label id="..."> ... tag, this
generate the raw text of the label it does not generate the html tag
<label ...> and i think we should generate and we should add ad "id"
attribute to the <label> tag, so some how we can manage the label tag on a
ajax replace.

Now, I'm not sure how we can manage the label, we don't generate the label
on the SAX events, we generate the label on the XSLT, the thing is how can
we know that the ajax update should contains the label replacement? we can
generate always and the ajax update try to find the label, but don't
generate any error if we don't find, but looks like a hack.

any thoughts ?

Cheers,
-- 
Carlos Chávez


Re: [Forms] Bug in Ajax when changing widget state?

Posted by Carlos Chvez <cc...@agssa.net>.
Hi Grzegorz.

Grzegorz Kossakowski Escribio :-)
> Carlos pisze:
>> Hi People,
>
> Hi Carlos,
>
> I found your e-mail little bit broken (weird characters in author field
> for example) that made my
> Thunderbird gone crazy. Is it your e-mail program issue?

I think so.
I'm using the Squirrel mail and it's a encoding problem, if i change to
ISO-8859-1 it show the "a" with the accent.

>
>> I found the message above that it's an old message, but that still being
>> an
>> issue on CForms.
>>
>> I found that the label field is not visible again because we only sent
>> the
>> <bu:replace> <span id="..."> ...</span> </bu:replace> for the input
>> field
>> but for the label we don't have anything similar.
>>
>> When we show the form that initially have a field invisible and the
>> field
>> it's on a <fi:group> ... we sent a placeholder for the field and this
>> generate this:
>>
>> <label class="forms placeholder" id="field2:label" for="field2:input"
>> title=""/>
>>
>> and
>>
>> <span id="field2"/>
>>
>> for example for a field "field2" (that is because the XSLT, now we only
>> generate the SAX's event only for the input, the label tag is generate
>> because the XSLT)
>
> Do you use some non-standard XSLT files? In normal situation it's a
> template duty to generate
> fi:label tags and XSLT only transforms them into HTML. Isn't it a case for
> you?

  I think you missed my point, I did a simple sample using the XSLT from
cocoon, of course the <label> and the <span> it was generated by the
XSLT
and the fi:label came from the template, the info it was only to show
what is in HTML generated.

>
>> Now, when we got visible the field, the <bu:replace> <span id="...">
>> it's
>> just only for the field, we don't manage in anyway the label tag.
>>
>> This is similar if the field it's initially visible, when we got
>> invisible
>> the input field is gone, but the label still there because we don't
>> manage
>> the label on the ajax update.
>>
>> This is similar too when we use the <widget-label id="..."> ... tag,
>> this
>> generate the raw text of the label it does not generate the html tag
>> <label ...> and i think we should generate and we should add ad "id"
>> attribute to the <label> tag, so some how we can manage the label tag on
>> a
>> ajax replace.
>>
>> Now, I'm not sure how we can manage the label, we don't generate the
>> label
>> on the SAX events, we generate the label on the XSLT, the thing is how
>> can
>> we know that the ajax update should contains the label replacement? we
>> can
>> generate always and the ajax update try to find the label, but don't
>> generate any error if we don't find, but looks like a hack.
>>
>> any thoughts ?
>
> My gut feeling is that it's a bug in macros responsible for handling form
> template and generating
> fi:* tags.

Yes, the thing is, we don't generate any info for the label of the widget
we generate the fi:field info what contains the label, then we use this
info in the XSLT to generate the input and the label. I not sure if the
solution is that simple than to sent more info to the XSLT indicating that
we are on a AJAX update and for the input generate the label.

> Before we dig into details of Forms implementation I would
> really like to see form
> definition and form template exhibiting behavior you are talking about.

  This is the sample, i added in the cocoon forms sample:

--------------
  flow:
--------------

  function do_testlabelajaxupdate() {
    var form = new Form("forms/testlabelajaxupdate.xml");
    form.showForm("testlabelajaxupdate-display-pipeline.jx");
  }

------------------
   Definition:
------------------

   <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1">

  <fd:widgets>
    <fd:field id="field">
      <fd:label>field</fd:label>
      <fd:hint>field hint</fd:hint>
      <fd:help>field help</fd:help>
      <fd:datatype base="string"/>
    </fd:field>
    <fd:field id="field2" state="invisible">
      <fd:label>field 2</fd:label>
      <fd:hint>field 2 hint</fd:hint>
      <fd:help>field 2 help</fd:help>
      <fd:datatype base="string"/>
    </fd:field>
    <fd:field id="field3">
      <fd:label>field 3</fd:label>
      <fd:hint>field 3 hint</fd:hint>
      <fd:help>field 3 help</fd:help>
      <fd:datatype base="string"/>
    </fd:field>
    <fd:action id="show">
      <fd:label>show ...</fd:label>
      <fd:on-action>
        <fd:javascript>
          widget.getForm().getChild("field").setState(org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
          widget.getForm().getChild("field2").setState(org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
          widget.getForm().getChild("field3").setState(org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
        </fd:javascript>
      </fd:on-action>
    </fd:action>
    <fd:action id="hide">
      <fd:label>hide ...</fd:label>
      <fd:on-action>
        <fd:javascript>
          widget.getForm().getChild("field").setState(org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
          widget.getForm().getChild("field2").setState(org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
          widget.getForm().getChild("field3").setState(org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
        </fd:javascript>
      </fd:on-action>
    </fd:action>
  </fd:widgets>
</fd:form>

--------------------
    template:
--------------------

<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
  <!-- Import the macros that define CForms template elements -->
  <jx:import
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
  <h4 class="samplesGroup">widgets States sample</h4>
  <title>Sample form</title>
  <content>
    <ft:form-template action="#{$cocoon/continuation/id}.continue"
method="POST" ajax="true">
      <fi:group>
        <fi:styling layout="columns"/>
        <fi:items>
          <ft:widget id="field"/>
          <ft:widget id="field2"/>
        </fi:items>
      </fi:group>
     <div>
        <ft:widget-label id="field3"/><ft:widget id="field3"/>
      </div>
      <ft:widget id="show"/>
      <ft:widget id="hide"/>
    </ft:form-template>
  </content>
</page>

>
>
> Also, have you tried following construct:
> <ft:widget id="...">
>   <ft:widget-label id="..."/>
> </ft:widget>
>
> I'm not sure how it will work but it is worth trying :-)

  That does not work ;)


   Cheers,
   Carlos Chávez.

>
> --
> Grzegorz Kossakowski
>


Re: [Forms] Bug in Ajax when changing widget state?

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Carlos pisze:
> Hi People,

Hi Carlos,

I found your e-mail little bit broken (weird characters in author field for example) that made my
Thunderbird gone crazy. Is it your e-mail program issue?

> I found the message above that it's an old message, but that still being an
> issue on CForms.
> 
> I found that the label field is not visible again because we only sent the
> <bu:replace> <span id="..."> ...</span> </bu:replace> for the input field
> but for the label we don't have anything similar.
> 
> When we show the form that initially have a field invisible and the field
> it's on a <fi:group> ... we sent a placeholder for the field and this
> generate this:
> 
> <label class="forms placeholder" id="field2:label" for="field2:input"
> title=""/>
> 
> and
> 
> <span id="field2"/>
> 
> for example for a field "field2" (that is because the XSLT, now we only
> generate the SAX's event only for the input, the label tag is generate
> because the XSLT)

Do you use some non-standard XSLT files? In normal situation it's a template duty to generate
fi:label tags and XSLT only transforms them into HTML. Isn't it a case for you?

> Now, when we got visible the field, the <bu:replace> <span id="..."> it's
> just only for the field, we don't manage in anyway the label tag.
> 
> This is similar if the field it's initially visible, when we got invisible
> the input field is gone, but the label still there because we don't manage
> the label on the ajax update.
> 
> This is similar too when we use the <widget-label id="..."> ... tag, this
> generate the raw text of the label it does not generate the html tag
> <label ...> and i think we should generate and we should add ad "id"
> attribute to the <label> tag, so some how we can manage the label tag on a
> ajax replace.
> 
> Now, I'm not sure how we can manage the label, we don't generate the label
> on the SAX events, we generate the label on the XSLT, the thing is how can
> we know that the ajax update should contains the label replacement? we can
> generate always and the ajax update try to find the label, but don't
> generate any error if we don't find, but looks like a hack.
> 
> any thoughts ?

My gut feeling is that it's a bug in macros responsible for handling form template and generating
fi:* tags. Before we dig into details of Forms implementation I would really like to see form
definition and form template exhibiting behavior you are talking about.


Also, have you tried following construct:
<ft:widget id="...">
  <ft:widget-label id="..."/>
</ft:widget>

I'm not sure how it will work but it is worth trying :-)

-- 
Grzegorz Kossakowski