You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by 黄 海冬 <li...@hotmail.com> on 2005/11/07 17:07:06 UTC

portal+cform+ajax problem in 2.1.8 rc1

Hi,all
  I try to combine portal+form(with ajax) in 2.1.8 rc1,all is fine but one 
problem,I don't know if is a bug,and just show my step here:
  1.change block portal in samples,copletdata.xml,config like:
     <coplet-data id="app-test-two" name="standard">
      <title>Application Test</title>
      <coplet-base-data>CachingURICoplet</coplet-base-data>
      <attribute>
         <name>buffer</name>
         <value xsi:type="java:java.lang.Boolean">true</value>
      </attribute>
      <attribute>
         <name>handleParameters</name>
         <value xsi:type="java:java.lang.Boolean">true</value>
      </attribute>
      <attribute>
         <name>uri</name>
         <value 
xsi:type="java:java.lang.String">cocoon:/coplets/html/application</value>
      </attribute>
      <attribute>
         <name>temporary:application-uri</name>
         <value 
xsi:type="java:java.lang.String">cocoon://samples/blocks/forms/do-datasourceChooser.flow</value>

      </attribute>
   </coplet-data>
   I just point the url to a form ajax sample
   2.change portal skin files to make form render correctly.
   3.change form block datasource_chooser_template.xml,from 
   <ft:form-template action="#{$cocoon/continuation/id}.continue" 
method="POST" ajax="true">
   to
       <ft:form-template action="continue" method="POST" ajax="true" 
ajax-action="/samples/blocks/forms/continue">
      <ft:continuation-id/>
    this change will still make the sample run good.
    
    Now I run the server and enter portal block sample,it works fine only 
when finally I click "ok" button.
    If it is not a ajax form or run the form seperatly,I should see the 
result information,but now I see the form restart.
    
    I check the aceess log and add some debug code in js file,the 
flowscript did't run after
    form.showForm("datasource_chooser-display-pipeline.jx");
    and the seperate form sample will run continue twice when I click "ok" 
but only once under this condition.
    
    I guess the ajax code missing one click to make showForm complete in 
this situation,so it may be a bug.
    
    Regards
    
    Roy Huang

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com  


Re: portal+cform+ajax problem in 2.1.8 rc1

Posted by Philippe Gassmann <ph...@anyware-tech.com>.
Sylvain Wallez wrote:

>黄 海冬 wrote:
>  
>
>>Hi,all
>>I try to combine portal+form(with ajax) in 2.1.8 rc1,all is fine but
>>one problem,I don't know if is a bug,and just show my step here:
>>    
>>
>
><snip/>
>
>  
>
>>Now I run the server and enter portal block sample,it works fine only
>>when finally I click "ok" button.
>>If it is not a ajax form or run the form seperatly,I should see the
>>result information,but now I see the form restart.
>>I check the aceess log and add some debug code in js file,the
>>flowscript did't run after
>>form.showForm("datasource_chooser-display-pipeline.jx");
>>and the seperate form sample will run continue twice when I click "ok"
>>but only once under this condition.
>>I guess the ajax code missing one click to make showForm complete in
>>this situation,so it may be a bug.
>>    
>>
>
>Well, my colleagues that succeeded in using CForms+Ajax in the portal
>told me this is much more complicated than that, and I shamely admit
>that I haven't understood their explanations.
>
>So it's not really a bug: the CForms+Ajax coplets must be written in a
>very special way. I'll try to have a better answer tomorrow, as we're
>here past the work hours now.
>
>Sylvain
>
>  
>
Hi, I will try to give you an explanation of how it can be done :
1. the pipeline called by the coplet containing the form is something
like this :

<map:match pattern="myForm">
<map:select type="request-method">
<map:when test="GET">
<map:call function="MyFlowFunctionThatCreateAndDisplayTheForm">
</map:when>
<map:otherwise>
<map:call continuation="{request-param:continuation-id}"/>
</map:otherwise>
</map:select
</map:select>

2. the pipeline showing the form is somewhat like this :
<map:patch pattern="showMyForm">
<map:generate type="jx" src="..."/>
<map:transform type="browser-update"/>

<map:transform type="i18n" label='i18n'>
<map:parameter name="locale"
value="{session-context:authentication/authentication/data/lang}"/>
</map:transform>

<map:transform src="somewhere/cocoon forms xsl.xsl" label='forms-xsl'>
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="lang"
value="{session-context:authentication/authentication/data/lang}"/>
</map:transform>

<map:select type="request-parameter">
<map:parameter name="parameter-name" value="cocoon-ajax"/>
<map:when test="true">
<map:serialize type="xml"/>
</map:when>
<map:otherwise>
<map:serialize type='xhtml'/>
</map:otherwise>
</map:select>
</map:match>

3. In the template :
<ft:form-template action="portal" enctype="multipart/form-data"
method="POST" ajax="true"
ajax-action="myForm"/>


Note :
- I assume that these pipeline are in the portal sitemap. If not, just
modify ajax-action
- We do not use the temporary attribute "application-uri". (the uri of
the coplet is always cocoon://portal/myForm in this case)

I think that's all.

Good luck !

-- 
Philippe GASSMANN
ANYWARE TECHNOLOGIES
http://www.anyware-tech.com/


Re: portal+cform+ajax problem in 2.1.8 rc1

Posted by Sylvain Wallez <sy...@apache.org>.
黄 海冬 wrote:
> Hi,all
> I try to combine portal+form(with ajax) in 2.1.8 rc1,all is fine but
> one problem,I don't know if is a bug,and just show my step here:

<snip/>

> Now I run the server and enter portal block sample,it works fine only
> when finally I click "ok" button.
> If it is not a ajax form or run the form seperatly,I should see the
> result information,but now I see the form restart.
> I check the aceess log and add some debug code in js file,the
> flowscript did't run after
> form.showForm("datasource_chooser-display-pipeline.jx");
> and the seperate form sample will run continue twice when I click "ok"
> but only once under this condition.
> I guess the ajax code missing one click to make showForm complete in
> this situation,so it may be a bug.

Well, my colleagues that succeeded in using CForms+Ajax in the portal
told me this is much more complicated than that, and I shamely admit
that I haven't understood their explanations.

So it's not really a bug: the CForms+Ajax coplets must be written in a
very special way. I'll try to have a better answer tomorrow, as we're
here past the work hours now.

Sylvain

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