You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John Meredith <ps...@t-online.de> on 2003/08/06 16:54:34 UTC

Parameter and direction="form" question

Hi,

I've been trying to split a form into component sections so that I can
use these sections individually on other pages. The sections themselves
only contain the form fields (not the form itself) and get their data
from via a parameter ie.:

<component-specification>
  <parameter name="customer" type="com.psynix.hibernate.Customer"
direction="form" required="yes"/>

  <bean name="requiredString"
class="org.apache.tapestry.valid.StringValidator" lifecycle="page">
    <set-property name="required" expression="true"/>
  </bean>

  <component id="customerName" type="ValidField">
    <binding name="value" expression="customer.name"/>
    <binding name="validator" expression="beans.requiredString"/>
    <message-binding name="displayName" key="customer.name"/>
  </component>
</component-specification>

The call to the component being:

<span jwcid="@CustDetailsForm" customer="ognl:customer"/>

The customer property of the containing page is initialised in a
pageBeginRender() method and defined as:

<property-specification name="customer"
type="com.psynix.hibernate.Customer"/>

On initial rendering of the page, everything works ok, however, when I
submit the form the following error occurs:

java.lang.ClassCastException Stack Trace:

org.apache.tapestry.param.AbstractParameterConnector.resetParameter(AbstractParameterConnector.java:189)
org.apache.tapestry.param.ParameterManager.resetParameters(ParameterManager.java:166)
org.apache.tapestry.AbstractComponent.cleanupAfterRender(AbstractComponent.java:971)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:902)
org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:673)
org.apache.tapestry.form.Form.renderComponent(Form.java:394)
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:896)
org.apache.tapestry.form.Form.rewind(Form.java:598)
org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:475)
org.apache.tapestry.form.Form.trigger(Form.java:612)
org.apache.tapestry.engine.DirectService.service(DirectService.java:203)
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:913)
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:238)
org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:367)
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

Does anyone have a clue what I might be doing wrong here ... it's
driving me nuts :-(

TIA,

  - John

-- 
John Meredith <ps...@t-online.de>


Re: Parameter and direction="form" question

Posted by John Meredith <ps...@t-online.de>.
Okay, that works. Thanks.

Arising from this would be my next question of when you would use
direction="form" at all?

>From the docs:

form means that the property is set from the parameter when the
component renders (as with in). When the form is submitted, the value is
read from the property and used to set the binding value after the
component rewinds.

I'm a little confused ... this seems to be exactly what I would need
(hence the reason I was trying it out).

At least it's working now :-)

  - John

On Wed, 2003-08-06 at 17:03, Harish Krishnaswamy wrote:
> Did you try direction "auto"? I think that's what you want here.
> 
> -Harish
> 
> John Meredith wrote:
> 
> >Hi,
> >
> >I've been trying to split a form into component sections so that I can
> >use these sections individually on other pages. The sections themselves
> >only contain the form fields (not the form itself) and get their data
> >from via a parameter ie.:
> >
> ><component-specification>
> >  <parameter name="customer" type="com.psynix.hibernate.Customer"
> >direction="form" required="yes"/>
> >
> >  <bean name="requiredString"
> >class="org.apache.tapestry.valid.StringValidator" lifecycle="page">
> >    <set-property name="required" expression="true"/>
> >  </bean>
> >
> >  <component id="customerName" type="ValidField">
> >    <binding name="value" expression="customer.name"/>
> >    <binding name="validator" expression="beans.requiredString"/>
> >    <message-binding name="displayName" key="customer.name"/>
> >  </component>
> ></component-specification>
> >
> >The call to the component being:
> >
> ><span jwcid="@CustDetailsForm" customer="ognl:customer"/>
> >
> >The customer property of the containing page is initialised in a
> >pageBeginRender() method and defined as:
> >
> ><property-specification name="customer"
> >type="com.psynix.hibernate.Customer"/>
> >
> >On initial rendering of the page, everything works ok, however, when I
> >submit the form the following error occurs:
> >
> >java.lang.ClassCastException Stack Trace:
> >
> >org.apache.tapestry.param.AbstractParameterConnector.resetParameter(AbstractParameterConnector.java:189)
> >org.apache.tapestry.param.ParameterManager.resetParameters(ParameterManager.java:166)
> >org.apache.tapestry.AbstractComponent.cleanupAfterRender(AbstractComponent.java:971)
> >org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:902)
> >org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:673)
> >org.apache.tapestry.form.Form.renderComponent(Form.java:394)
> >org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:896)
> >org.apache.tapestry.form.Form.rewind(Form.java:598)
> >org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:475)
> >org.apache.tapestry.form.Form.trigger(Form.java:612)
> >org.apache.tapestry.engine.DirectService.service(DirectService.java:203)
> >org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:913)
> >org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:238)
> >org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:367)
> >javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> >javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >
> >Does anyone have a clue what I might be doing wrong here ... it's
> >driving me nuts :-(
> >
> >TIA,
> >
> >  - John
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
-- 
John Meredith <ps...@t-online.de>


Re: Parameter and direction="form" question

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Did you try direction "auto"? I think that's what you want here.

-Harish

John Meredith wrote:

>Hi,
>
>I've been trying to split a form into component sections so that I can
>use these sections individually on other pages. The sections themselves
>only contain the form fields (not the form itself) and get their data
>from via a parameter ie.:
>
><component-specification>
>  <parameter name="customer" type="com.psynix.hibernate.Customer"
>direction="form" required="yes"/>
>
>  <bean name="requiredString"
>class="org.apache.tapestry.valid.StringValidator" lifecycle="page">
>    <set-property name="required" expression="true"/>
>  </bean>
>
>  <component id="customerName" type="ValidField">
>    <binding name="value" expression="customer.name"/>
>    <binding name="validator" expression="beans.requiredString"/>
>    <message-binding name="displayName" key="customer.name"/>
>  </component>
></component-specification>
>
>The call to the component being:
>
><span jwcid="@CustDetailsForm" customer="ognl:customer"/>
>
>The customer property of the containing page is initialised in a
>pageBeginRender() method and defined as:
>
><property-specification name="customer"
>type="com.psynix.hibernate.Customer"/>
>
>On initial rendering of the page, everything works ok, however, when I
>submit the form the following error occurs:
>
>java.lang.ClassCastException Stack Trace:
>
>org.apache.tapestry.param.AbstractParameterConnector.resetParameter(AbstractParameterConnector.java:189)
>org.apache.tapestry.param.ParameterManager.resetParameters(ParameterManager.java:166)
>org.apache.tapestry.AbstractComponent.cleanupAfterRender(AbstractComponent.java:971)
>org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:902)
>org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:673)
>org.apache.tapestry.form.Form.renderComponent(Form.java:394)
>org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:896)
>org.apache.tapestry.form.Form.rewind(Form.java:598)
>org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:475)
>org.apache.tapestry.form.Form.trigger(Form.java:612)
>org.apache.tapestry.engine.DirectService.service(DirectService.java:203)
>org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:913)
>org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:238)
>org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:367)
>javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
>Does anyone have a clue what I might be doing wrong here ... it's
>driving me nuts :-(
>
>TIA,
>
>  - John
>
>  
>