cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Clark" <Chris.Cl...@teranet.ca>
Subject RE: Checkboxes in JXForms - javascript OK, java NOT
Date Thu, 21 Aug 2003 18:38:32 GMT
I'm using xf:itemset at the moment.  Never seen the jx:ForEach before which gets back to one
of my original questions:
Are there any docs for jxForms yet?  If so, where?

Regardless of whether I use the itemset or not, I can get my checkboxes to display correctly
on the screen.
The problem comes when I want to capture the state of the checkboxes.

If I define my model in javascript with a "var results[""]" then it works okay.  I get back
an array of strings.

If I define my model in a Java Bean and pass it to the form after instantiating with "var
model = new Packages.path.class()",
then it doesn't work.  If the bean defines the results as a String[], then I get the cast
exception (previous email).  If I define results as a single String, then I get the id of
the first checked checkbox, but none of the others.  I tried initializing my array of Strings
in my java class but it didn't make a difference whether it was or not.

Right now I'm going with the slightly kludgy workaround of using a javascript model for the
form and then copying it to my Java Bean after submission.

> -----Original Message-----
> From:	Christopher Oliver [SMTP:res1cf5x@verizon.net]
> Sent:	Thursday, August 21, 2003 2:21 PM
> To:	dev@cocoon.apache.org
> Subject:	Re: Checkboxes in JXForms - javascript OK, java NOT
> 
> Why not use xf:itemset in this case instead of jx:forEach?
> 
> Giacomo Pati wrote:
> 
> >On Thu, 21 Aug 2003, Chris Clark wrote:
> >
> >  
> >
> >>I think there may be a bug then...
> >>
> >>When I try to use a String array in my Java class, I get the following error:
> >>
> >>Exception trying to set value with xpath validchecks; Cannot modify property:
elrsproto.FormBean.validchecks; Cannot convert value of class java.lang.String to type class
[Ljava.lang.String;; Cannot convert class java.lang.String to class [Ljava.lang.String;
> >>
> >>That's why I tried to use just a straight String.  And it works, except that
it only gets the value of the first check.
> >>
> >>Whether I use the nodeset or not, I get the same behaviour.
> >>
> >>I did verify that I don't need to use the nodeset if I specify all of the controls
ahead of time in the form definition.  Thanks.
> >>
> >>For now my work-around is to use a javascript array object for the form and then
copy it into my Java class.  That works.  Odd.
> >>    
> >>
> >
> >Ok, let check:
> >
> >We use a Java Bean that has a:
> >
> >    private String [] m_roles;
> >
> >which gets initialized with an array from a database and the array size
> >fits the numbers of item we've stored in the database (even a
> >'m_roles = new String[ 0 ]' works for us).
> >
> >with setter/getter
> >
> >    public void setRoless( String [] roles )
> >    {
> >        m_roles = roles;
> >    }
> >    public String [] getRoless(  )
> >    {
> >        return m_roles;
> >    }
> >
> >and the form snipped we use look like:
> >
> >    <xf:select ref="/roless" appearance="full">
> >      <xf:label><i18n:text>ROLE</i18n:text></xf:label>
> >      <jx:forEach var="role" items="${allRoles}">
> >        <xf:item>
> >          <xf:label>${role.name}</xf:label>
> >          <xf:value>${role.name}</xf:value>
> >        </xf:item>
> >      </jx:forEach>
> >    </xf:select>
> >
> >Hope this helps.
> >
> >--
> >Giacomo Pati
> >Otego AG, Switzerland - http://www.otego.com
> >Orixo, the XML business alliance - http://www.orixo.com
> >
> >
> >  
> >
> 
> 

Mime
View raw message