You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Raphaël Piéroni <ra...@aql.fr> on 2007/10/18 16:39:18 UTC

[Cocoon 2.2 + Forms + Binding] a workable example.

Hi guys,

I still can't find a simple example on binding with forms.

Here is my use case :
i display a list of elements (taken from the database) with a link per 
item. (this is working correctly)
when i follow one of the edit link, i got no value in the resulting html 
page. (it seems to me that i don't have well binded my hibernate object, 
but can't find real infos on how to do it correctly)

I really have no ideas why my object values are not shown.

In advance, many thanks for any help

Regards,

Raphaël

Here is the excerpt of the flow for the edit:
Language.prototype.edit = function(languageId) {
    if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("Edit language " 
+ languageId); }
    if (languageId == undefined) {
        languageId = cocoon.request.getParameter("language");
    }
    if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("language=" + 
languageId); }
    var language = adminUiFacade.getLanguage(languageId);
    if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("from db lang=" 
+ language.getLanguage()); } /* Correctly executed */
    if (cocoon.log.isDebugEnabled()) { cocoon.log.debug("from db langT=" 
+ language.getLanguageT()); } /* too */
    var editLanguageForm = new Form("view/language/edit.cform");
    editLanguageForm.createBinding("view/language/edit.bind");
    editLanguageForm.load(language);
    editLanguageForm.showForm("view/language/edit.xml", {
            language: language
    });
    cocoon.sendPage("view/language/show.xml", {
            language: model
    });
}

Here is the full cform file:
<?xml version="1.0" encoding="UTF-8"?>
<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="language" required="true">
            <fd:label>Language</fd:label>
            <fd:datatype base="string"/>
        </fd:field>
        <fd:field id="languageT" required="true">
            <fd:label>Language T</fd:label>
            <fd:datatype base="string"/>
        </fd:field>
    </fd:widgets>
</fd:form>

Here is the full bind file:
<?xml version="1.0" encoding="UTF-8"?>
<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" path="/">
    <fb:value id="language" path="language"/>
    <fb:value id="languageT" path="languageT"/>
</fb:context>

Here the full xml file:
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template" 
xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
    <site signOn="false" view="cforms">
        <ft:form-template action="${cocoon.continuation.id}.cont" 
method="POST">
            <fi:group>
                <fi:label>User Information</fi:label>
                <fi:items>
                    <ft:widget id="language"/>
                    <ft:widget id="languageT"/>
                </fi:items>
            </fi:group>
            <input type="submit" name="save" value="Save" />
            <input type="submit" name="cancel" value="Cancel" />
        </ft:form-template>
    </site>
</page>

And now my result with cocoon-view=debug
<?xml version="1.0" encoding="ISO-8859-1"?><page 
xmlns:ft="http://apache.org/cocoon/forms/1.0#template" 
xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
    <site signOn="false" view="cforms">
        <ft:form-template 
action="2c87533d3375788b261f257d431056575d583c82.cont" method="POST">
            <fi:group>
                <fi:label>User Information</fi:label>
                <fi:items>
                    <ft:widget id="language"/>
                    <ft:widget id="languageT"/>
                </fi:items>
            </fi:group>
            <input type="submit" name="save" value="??? Save ???"/>
            <input type="submit" name="cancel" value="??? Cancel ???"/>
        </ft:form-template>
    </site>
</page>

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


Re: [Cocoon 2.2 + Forms + Binding] a workable example.

Posted by Raphaël Piéroni <ra...@aql.fr>.
The trick was written in the doco !
i needed to add <jx:import 
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml" />
in my form template file

Raphaël

Raphaël Piéroni a écrit :
> Joerg Heinicke a écrit :
>> On 10/18/07 10:39 AM, Raphaël Piéroni wrote:
>>
>>> I still can't find a simple example on binding with forms.
>>
>> What about the samples that come with Cocoon?
>>
>> Joerg
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
> I digged the petstore and the cforms samples, but i still lack in
> understanding how to bind my data.
>
> Regards,
>
> Raphaël
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


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


Re: [Cocoon 2.2 + Forms + Binding] a workable example.

Posted by Raphaël Piéroni <ra...@aql.fr>.
Joerg Heinicke a écrit :
> On 10/18/07 10:39 AM, Raphaël Piéroni wrote:
>
>> I still can't find a simple example on binding with forms.
>
> What about the samples that come with Cocoon?
>
> Joerg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
I digged the petstore and the cforms samples, but i still lack in
understanding how to bind my data.

Regards,

Raphaël

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


Re: [Cocoon 2.2 + Forms + Binding] a workable example.

Posted by Joerg Heinicke <jo...@gmx.de>.
On 10/18/07 10:39 AM, Raphaël Piéroni wrote:

> I still can't find a simple example on binding with forms.

What about the samples that come with Cocoon?

Joerg

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