You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Bruno Dumon <br...@outerthought.org> on 2004/04/28 20:39:16 UTC
Re: Accessing repeater in xsp Using V2 woody
On Wed, 2004-04-28 at 21:14, JD Daniels wrote:
> Hi all,
>
> I want do soemthing like this from the samples:
>
> Flow:
>
> // also store the form as a request attribute as the XSP isn't
> flow-aware
> cocoon.request.setAttribute("form_model_gui", form.getWidget());
> cocoon.sendPage("form_model_gui-success-pipeline.xsp");
>
> XSP:
>
> <xsp:structure>
> <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
> </xsp:structure>
> <p>
> <xsp:logic>
> // get reference to form and some of the widgets on it
> Form form = (Form)request.getAttribute("form_model_gui");
> Repeater repeater = (Repeater)form.getWidget("widgets");
> </xsp:logic>
>
> Repeater has <xsp:expr>repeater.getSize()</xsp:expr> row(s).
> </p>
>
> Using V2, I get a classCastException on Form form =
> (Form)request.getAttribute("form_model_gui");
>
> Anyone know why?
With V2, the object you get from form.getWidget() isn't the java Form
object itself but a javascript adapter for it. The real java form object
is also stored in a request attribute called "CocoonFormsInstance", so
doing:
Form form = (Form)request.getAttribute("CocoonFormsInstance");
in the xsp should work.
--
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
RE: Accessing repeater in xsp Using V2 woody
Posted by JD Daniels <jd...@datatrio.com>.
Yes i poked around in form.js and found the reference...
woody-form still is a java.lang.NullPointerException
arg. I shouldn't need to setAttribute in the flow for it should I?
just:
Form form = (Form)request.getAttribute("woody-form");
should work?
sidenote: is there a way in xsp to get all the define request attributes?
JD
-----Original Message-----
From: Bruno Dumon [mailto:bruno@outerthought.org]
Sent: April 28, 2004 10:53 AM
To: users@cocoon.apache.org
Subject: RE: Accessing repeater in xsp Using V2 woody
On Wed, 2004-04-28 at 21:42, JD Daniels wrote:
> I am using 2.1.4 (pre cocoon forms)
>
> CocoonFormsInstance result sin a null pointer exception...
>
> What would the woody version be?
"woody-form"
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Accessing repeater in xsp Using V2 woody
Posted by JD Daniels <jd...@datatrio.com>.
oh crud nevermind... I was accessing the repeater incorrectly.. i have a
handle on the form now.....
-----Original Message-----
From: Bruno Dumon [mailto:bruno@outerthought.org]
Sent: April 28, 2004 10:53 AM
To: users@cocoon.apache.org
Subject: RE: Accessing repeater in xsp Using V2 woody
On Wed, 2004-04-28 at 21:42, JD Daniels wrote:
> I am using 2.1.4 (pre cocoon forms)
>
> CocoonFormsInstance result sin a null pointer exception...
>
> What would the woody version be?
"woody-form"
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Accessing repeater in xsp Using V2 woody
Posted by Bruno Dumon <br...@outerthought.org>.
On Thu, 2004-04-29 at 00:44, JD Daniels wrote:
> hmmm... i am confused again..
>
> <xsp:logic>
> Form form = (Form)request.getAttribute("woody-form");
> Field field = (Field)form.getWidget("customerId");
> </xsp:logic>
>
> The field customerId is there and has a value.. but it gives me
> java.lang.NullPointerException.. which makes me think with v2 I have to
> change how I get a handle on the widgets...
>
> any help?
sure, I actually didn't understand why you said in your other message
that it worked, as I suddenly thought of why it couldn't work: I assume
the XSP page is not the form template shown as part of form.showForm,
but a separate page after that? Then the woody-form isn't set in the
request object and you need to do that yourself.
I should warn though, that in fact you are not supposed to do this, as
the V2 API is designed to give you no access to the original java widget
(you'd better use the non-v2 api then) (I'm currently working on merging
both in a third proposal).
This should work:
cocoon.request.setAttribute("woody-form", form.formWidget_.unwrap());
--
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
RE: Accessing repeater in xsp Using V2 woody
Posted by JD Daniels <jd...@datatrio.com>.
Better put the whole thing in here again:
I am putting a form object into an xsp that is shown after form validation
with flow:
<xsp:logic>
Form form = (Form)request.getAttribute("woody-form");
Field field = (Field)form.getWidget("customerId");
</xsp:logic>
The form reference seems to be working ok, it is trying to access a widget
that it is dying on. The field customerId is there and has a value.. but it
gives me
java.lang.NullPointerException.. which makes me think with v2 I have to
change how I get a handle on the widgets...
any help?
JD
-----Original Message-----
From: Bruno Dumon [mailto:bruno@outerthought.org]
Sent: April 28, 2004 10:53 AM
To: users@cocoon.apache.org
Subject: RE: Accessing repeater in xsp Using V2 woody
On Wed, 2004-04-28 at 21:42, JD Daniels wrote:
> I am using 2.1.4 (pre cocoon forms)
>
> CocoonFormsInstance result sin a null pointer exception...
>
> What would the woody version be?
"woody-form"
--
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
---------------------------------------------------------------------
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: Accessing repeater in xsp Using V2 woody
Posted by JD Daniels <jd...@datatrio.com>.
hmmm... i am confused again..
<xsp:logic>
Form form = (Form)request.getAttribute("woody-form");
Field field = (Field)form.getWidget("customerId");
</xsp:logic>
The field customerId is there and has a value.. but it gives me
java.lang.NullPointerException.. which makes me think with v2 I have to
change how I get a handle on the widgets...
any help?
JD
-----Original Message-----
From: Bruno Dumon [mailto:bruno@outerthought.org]
Sent: April 28, 2004 10:53 AM
To: users@cocoon.apache.org
Subject: RE: Accessing repeater in xsp Using V2 woody
On Wed, 2004-04-28 at 21:42, JD Daniels wrote:
> I am using 2.1.4 (pre cocoon forms)
>
> CocoonFormsInstance result sin a null pointer exception...
>
> What would the woody version be?
"woody-form"
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: Accessing repeater in xsp Using V2 woody
Posted by Bruno Dumon <br...@outerthought.org>.
On Wed, 2004-04-28 at 21:42, JD Daniels wrote:
> I am using 2.1.4 (pre cocoon forms)
>
> CocoonFormsInstance result sin a null pointer exception...
>
> What would the woody version be?
"woody-form"
--
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
RE: Accessing repeater in xsp Using V2 woody
Posted by JD Daniels <jd...@datatrio.com>.
I am using 2.1.4 (pre cocoon forms)
CocoonFormsInstance result sin a null pointer exception...
What would the woody version be?
-----Original Message-----
From: Bruno Dumon [mailto:bruno@outerthought.org]
Sent: April 28, 2004 10:39 AM
To: users@cocoon.apache.org
Subject: Re: Accessing repeater in xsp Using V2 woody
On Wed, 2004-04-28 at 21:14, JD Daniels wrote:
> Hi all,
>
> I want do soemthing like this from the samples:
>
> Flow:
>
> // also store the form as a request attribute as the XSP isn't
> flow-aware
> cocoon.request.setAttribute("form_model_gui", form.getWidget());
> cocoon.sendPage("form_model_gui-success-pipeline.xsp");
>
> XSP:
>
> <xsp:structure>
> <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
> </xsp:structure>
> <p>
> <xsp:logic>
> // get reference to form and some of the widgets on it
> Form form = (Form)request.getAttribute("form_model_gui");
> Repeater repeater = (Repeater)form.getWidget("widgets");
> </xsp:logic>
>
> Repeater has <xsp:expr>repeater.getSize()</xsp:expr> row(s).
> </p>
>
> Using V2, I get a classCastException on Form form =
> (Form)request.getAttribute("form_model_gui");
>
> Anyone know why?
With V2, the object you get from form.getWidget() isn't the java Form
object itself but a javascript adapter for it. The real java form object
is also stored in a request attribute called "CocoonFormsInstance", so
doing:
Form form = (Form)request.getAttribute("CocoonFormsInstance");
in the xsp should work.
--
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org