cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: getting values of widgets inside <fd:union>
Date Tue, 20 Dec 2005 10:33:08 GMT
Andreas Deininger wrote:
> Hi,
>
> I encountering a problem with CForms:
>
> inside a multi-step wizard, I defined a selection-list of persons. The
> last item of that list is "Enter your own person data below". If you
> select that item, an imput mask for the person data appears. I got
> that working  with the code below. The form definition looks like:
>
> <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
>     xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
>   <fd:widgets>
>     <fd:union id="inputcontact" case="contactperson">
>       <fd:widgets>
>           <fd:field id="fullname" state="active">
>              <fd:datatype base="string" />
> 	         <fd:initial-value>Enter name here ...</fd:initial-value>
>           </fd:field>
>       </fd:widgets>
>     </fd:union>
>
>     <fd:field id="contactperson">
>       <fd:datatype base="string" />
>       <fd:selection-list>
>         <fd:item value="7944">
>           <fd:label>Person 1</fd:label>
>         </fd:item>
>         <fd:item value="-1">
>           <fd:label>Enter person below</fd:label>
>         </fd:item>
>       </fd:selection-list>
>     </fd:field>
>   </fd:widgets>
> </fd:form>
>
> And that's the relevant part of the template used:
>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> <ft:form-template action="${submitPath}" method="POST">
>     <ft:widget id="contactperson">
>        <fi:styling list-type="dropdown" submit-on-change="true"/>
>     </ft:widget>
>
>     <ft:union id="inputcontact">
>        <ft:case id="-1">
>           <ft:widget id="fullname" />
>        </ft:case>
>     </ft:union>
>     <input type="submit" value="Beitrag absenden" />
> </ft:form-template>
> </xsl:stylesheet>
>
> Everything works fine so far, if I select "Enter person below" from
> the selection list contactperson, the input field for fullname
> appears.
>
> The problem is that I would like to get the value of that field
> "fullname" inside an Apple. My code looks like that:
>
> protected void processInternal(AppleRequest appleRequest,
> AppleResponse appleResponse) throws Exception {
>   // handle form submit
>   if (request.getMethod().equals("POST")) {
>   logger.debug("Fullname:" +
> contactForm.lookupWidget("inputcontact/fullname").getValue());
>   }
> }
>
> While I can lookup the fullname widget successfully, I always get null
> if I invoke the getValue() method on that widget, so I am not able to
> retrieve the value of the input field. (I can get the values of all
> other widgets inside my form but not those values from the widgets
> inside the <union> tags.)
>
> Any idea what I am doing wrong or how I can overcome that problem?
>   

Hmm... the <fd:union> widget considers children having the same name as 
the value of the "case" widget.

In other words, when you select "-1", the union tries to get its child 
named "-1" for it to process the request. In your case, it doesn't exist.

Have a look at the datasource example in CForms to see more about this.

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://bluxte.net                     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


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


Mime
View raw message