You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Marcin Okraszewski <ok...@o2.pl> on 2003/11/17 11:30:42 UTC

Woody problem: woody isn't saving added row entries to bean.

Hi,
Can anyone can tell me, why Woody doesn't add beans corresponding to 
rows in repeater? It isn't even calling the constructor of row bean. It 
works fine with rows that were included earlier (it updates them).

I have an default contructor in row beans and "wb:on-insert-row" in 
bind. All packages and class names were copied just for sure.

There is frow script, binding, classes below.

Regards,
Marcin Okraszewski

--------------------
Flow:

bean = new Packages.eti.beans.Entry(cocoon.request.get("entry"));
form.load(bean);
form.showForm("admin/entry-form.xml.html");
form.save(bean);
bean.save();
cocoon.redirectTo("/index.html");

--------------------
Bind-bean:
<wb:context xmlns:wb="http://apache.org/cocoon/woody/binding/1.0" path="/" >

   <wb:value id="importance" path="importance"/>
   <wb:repeater id="translations"
         parent-path="."
         row-path="translations"
         unique-row-id="language"
         unique-path="@savedLang">

     <wb:on-bind>
       <wb:value id="language" path="lang"/>
       <wb:value id="title" path="title"/>
       <wb:value id="digest" path="digest"/>
       <wb:value id="body" path="body"/>
     </wb:on-bind>

     <wb:on-insert-row>
       <wb:insert-bean
         classname="eti.beans.EntryTranslation"
         addmethod="addTranslation"/>
     </wb:on-insert-row>

   </wb:repeater>
</wb:context>

-------------------
Entry-model:
<wd:form
   xmlns:wd="http://apache.org/cocoon/woody/definition/1.0"
   xmlns:i18n="http://apache.org/cocoon/i18n/2.1">

   <wd:field id="tabstate">
     <wd:datatype base="long"/>
   </wd:field>

   <wd:field id="importance">
     <wd:label>importance</wd:label>
     <wd:datatype base="long"/>
   </wd:field>

   <wd:repeater id="translations">

     <wd:field id="language">
       <wd:label>language</wd:label>
       <wd:datatype base="string"/>
     </wd:field>

     <wd:field id="title">
       <wd:label>title</wd:label>
       <wd:datatype base="string"/>
     </wd:field>

     <wd:field id="digest">
       <wd:label>abstract</wd:label>
       <wd:datatype base="string"/>
     </wd:field>

     <wd:field id="body">
       <wd:label>body</wd:label>
       <wd:datatype base="string"/>
     </wd:field>

   </wd:repeater>

   <wd:repeater-action id="add-translation" action-command="add-row" 
repeater="translations">
     <wd:label>add translation</wd:label>
   </wd:repeater-action>

   <wd:submit id="next" action-command="next">
       <wd:label>next &gt;&gt;</wd:label>
   </wd:submit>
</wd:form>

--------------------------
class Entry (just methods)

public class Entry extends com.okrasz.db.sql.DbTableHSQLDB implements 
java.io.Serializable {
     public Entry();
     public Entry(int entryId) throws SQLException;
     public long getEntryId();
     public long getImportance();
     public void setImportance(long importance);
     public Collection getTranslations();
     public void setTranslations(Collection trans);
     public void addTranslation(EntryTranslation t);
     public EntryTranslation getTranslation(String lang);
     public void removeTranslation(String lang);
}

---------------------
class EntryTranslation (just methods)

public class EntryTranslation extends com.okrasz.db.sql.DbTableHSQLDB {
     public EntryTranslation();
     public EntryTranslation(Entry parent, ResultSet rs) throws 
SQLException;
     public java.lang.String getLang();
     public void setLang(java.lang.String lang);
     public java.lang.String getSavedLang();
     public java.lang.String getTitle();
     public void setTitle(java.lang.String title);
     public java.lang.String getDigest();
     public void setDigest(java.lang.String digest);
     public java.lang.String getBody();
     public void setBody(java.lang.String body);
}

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


Re: Woody problem: woody isn't saving added row entries to bean.

Posted by Bruno Dumon <br...@outerthought.org>.
On Mon, 2003-11-17 at 11:30, Marcin Okraszewski wrote:
> Hi,
> Can anyone can tell me, why Woody doesn't add beans corresponding to 
> rows in repeater? It isn't even calling the constructor of row bean. It 
> works fine with rows that were included earlier (it updates them).
> 
> I have an default contructor in row beans and "wb:on-insert-row" in 
> bind. All packages and class names were copied just for sure.
> 
> There is frow script, binding, classes below.

<snip/>

>    <wb:value id="importance" path="importance"/>
>    <wb:repeater id="translations"
>          parent-path="."
>          row-path="translations"
>          unique-row-id="language"
>          unique-path="@savedLang">
<snip/>

Are you sure there isn't already another row bean with the same language
in the destination collection?

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


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