You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Random Tapestry User <ta...@comcast.net> on 2005/04/30 22:23:49 UTC

Shared beans ?

Hey all,

I think I'm missing something simple. I've read the book, but not sure 
if I came across how to do this, or wasn't sure what I was looking at if 
I did.

I have a number of pages, that use the same component.

Here's what I have.

I have a user registration page, "RegisterUser.page", with a first and 
last name component, and html template, named "UserNameElements.jwc", 
and "UserNameElements.html".
I also have a user update page, "EditUser.page" which uses the same 
"UserNameElements.jwc" component.

The first and last name, are required elements in the 
"UserNameElements.jwc", however, I find I'm having to define the 
"required" bean, and my form "delegate" bean in both the 
"RegisterUser.page" and in the "EditUser.page".

Since only the "UserNameElements.jwc" use the "required" and "delegate" 
beans (in this simple example), isn't there somewhere I can define 
those, perhaps in the "UserNameElements.jwc" ?

Thanks all,
tappapp

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Still having errors : Re: Shared beans ?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On May 2, 2005, at 10:30 PM, Random Tapestry User wrote:

> Hmmm.
>
> Thanks Erik.
>
> I defined a method in my base class with a getter for getting a  
> ValidationDelegate, and loading the page no longer throws an error.
> However, when I submit the form, and the validation is triggered,  
> an runtime exception is thrown "Component InvestorEditor does not  
> define a bean name delegate." The stack trace shows tapestry is  
> looking to the bean provider to provide a delegate bean.

I don't see the error in what you've done, sorry.  Somewhere you must  
have a dangling reference to beans.delegate, is my guess.

>
> Here's my page spec
>
> <?xml version="1.0"?>
> <!DOCTYPE page-specification PUBLIC
>  "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
>  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
> <page-specification  
> class="com.ughm.app.view.tapestry.pages.entities.users.investor.Invest 
> orEditorPage">
>
>    <property-specification name="editUser"
>        type="com.ughm.entities.users.Investor"
>        persistent="no"/>
>
>        <bean name="required"
>        class="org.apache.tapestry.valid.StringValidator"
>        lifecycle="page">
>        <set-property name="required" expression="true"/>
>    </bean>

You can do the same trick for StringValidator as well, so you don't  
need a <bean> for it.

>    <component id="editForm" type="Form">
>        <binding name="listener" expression="listeners.formSubmit" />
>        <binding name="delegate" expression="investorDelegate" />
>    </component>  </page-specification>
>
> Note I have an accessor expression "investorDelegate" that should  
> resolve to the following method on the base class :
> public InvestorUserDelegate getInvestorDelegate()
>  {     return new InvestorUserDelegate();
>  }

I would recommend you use an instance variable for the delegate and  
any other objects created like this.  And clear them in an initialize 
() method.

>
> Not sure what I'm doing wrong, but it appears Tapestry is expecting  
> a bean to be found for the delegate binding.
>
> ??
>
> Thanks for any help here !
>
> tappapp
>
> Erik Hatcher wrote:
>
>
>> You don't need to use <bean> to define these things.  You can  
>> simply return an IValidator and ValidationDelegate from anywhere  
>> you like.  I've often used a base page class with getters for this  
>> purpose.
>>
>>     Erik
>>
>> On Apr 30, 2005, at 4:23 PM, Random Tapestry User wrote:
>>
>>
>>> Hey all,
>>>
>>> I think I'm missing something simple. I've read the book, but not  
>>> sure if I came across how to do this, or wasn't sure what I was  
>>> looking at if I did.
>>>
>>> I have a number of pages, that use the same component.
>>>
>>> Here's what I have.
>>>
>>> I have a user registration page, "RegisterUser.page", with a  
>>> first and last name component, and html template, named  
>>> "UserNameElements.jwc", and "UserNameElements.html".
>>> I also have a user update page, "EditUser.page" which uses the  
>>> same "UserNameElements.jwc" component.
>>>
>>> The first and last name, are required elements in the  
>>> "UserNameElements.jwc", however, I find I'm having to define the  
>>> "required" bean, and my form "delegate" bean in both the  
>>> "RegisterUser.page" and in the "EditUser.page".
>>>
>>> Since only the "UserNameElements.jwc" use the "required" and  
>>> "delegate" beans (in this simple example), isn't there somewhere  
>>> I can define those, perhaps in the "UserNameElements.jwc" ?
>>>
>>> Thanks all,
>>> tappapp
>>>
>>> -------------------------------------------------------------------- 
>>> -
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user- 
>>> help@jakarta.apache.org
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user- 
>> help@jakarta.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Still having errors : Re: Shared beans ?

Posted by Random Tapestry User <ta...@comcast.net>.
Hmmm.

Thanks Erik.

I defined a method in my base class with a getter for getting a 
ValidationDelegate, and loading the page no longer throws an error.
However, when I submit the form, and the validation is triggered, an 
runtime exception is thrown "Component InvestorEditor does not define a 
bean name delegate." The stack trace shows tapestry is looking to the 
bean provider to provide a delegate bean.

Here's my page spec

<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<page-specification 
class="com.ughm.app.view.tapestry.pages.entities.users.investor.InvestorEditorPage">

    <property-specification name="editUser"
        type="com.ughm.entities.users.Investor"
        persistent="no"/>

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

    <component id="editForm" type="Form">
        <binding name="listener" expression="listeners.formSubmit" />
        <binding name="delegate" expression="investorDelegate" />
    </component>  
</page-specification>

Note I have an accessor expression "investorDelegate" that should 
resolve to the following method on the base class :
 public InvestorUserDelegate getInvestorDelegate()
  {  
    return new InvestorUserDelegate();
  }

Not sure what I'm doing wrong, but it appears Tapestry is expecting a 
bean to be found for the delegate binding.

??

Thanks for any help here !

tappapp

Erik Hatcher wrote:

> You don't need to use <bean> to define these things.  You can simply 
> return an IValidator and ValidationDelegate from anywhere you like.  
> I've often used a base page class with getters for this purpose.
>
>     Erik
>
> On Apr 30, 2005, at 4:23 PM, Random Tapestry User wrote:
>
>> Hey all,
>>
>> I think I'm missing something simple. I've read the book, but not 
>> sure if I came across how to do this, or wasn't sure what I was 
>> looking at if I did.
>>
>> I have a number of pages, that use the same component.
>>
>> Here's what I have.
>>
>> I have a user registration page, "RegisterUser.page", with a first 
>> and last name component, and html template, named 
>> "UserNameElements.jwc", and "UserNameElements.html".
>> I also have a user update page, "EditUser.page" which uses the same 
>> "UserNameElements.jwc" component.
>>
>> The first and last name, are required elements in the 
>> "UserNameElements.jwc", however, I find I'm having to define the 
>> "required" bean, and my form "delegate" bean in both the 
>> "RegisterUser.page" and in the "EditUser.page".
>>
>> Since only the "UserNameElements.jwc" use the "required" and 
>> "delegate" beans (in this simple example), isn't there somewhere I 
>> can define those, perhaps in the "UserNameElements.jwc" ?
>>
>> Thanks all,
>> tappapp
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Shared beans ?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
You don't need to use <bean> to define these things.  You can simply 
return an IValidator and ValidationDelegate from anywhere you like.  
I've often used a base page class with getters for this purpose.

	Erik

On Apr 30, 2005, at 4:23 PM, Random Tapestry User wrote:

> Hey all,
>
> I think I'm missing something simple. I've read the book, but not sure 
> if I came across how to do this, or wasn't sure what I was looking at 
> if I did.
>
> I have a number of pages, that use the same component.
>
> Here's what I have.
>
> I have a user registration page, "RegisterUser.page", with a first and 
> last name component, and html template, named "UserNameElements.jwc", 
> and "UserNameElements.html".
> I also have a user update page, "EditUser.page" which uses the same 
> "UserNameElements.jwc" component.
>
> The first and last name, are required elements in the 
> "UserNameElements.jwc", however, I find I'm having to define the 
> "required" bean, and my form "delegate" bean in both the 
> "RegisterUser.page" and in the "EditUser.page".
>
> Since only the "UserNameElements.jwc" use the "required" and 
> "delegate" beans (in this simple example), isn't there somewhere I can 
> define those, perhaps in the "UserNameElements.jwc" ?
>
> Thanks all,
> tappapp
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


BUMP, anyone ? : Shared beans ?

Posted by Random Tapestry User <ta...@comcast.net>.
Random Tapestry User wrote:

> Hey all,
>
> I think I'm missing something simple. I've read the book, but not sure 
> if I came across how to do this, or wasn't sure what I was looking at 
> if I did.
>
> I have a number of pages, that use the same component.
>
> Here's what I have.
>
> I have a user registration page, "RegisterUser.page", with a first and 
> last name component, and html template, named "UserNameElements.jwc", 
> and "UserNameElements.html".
> I also have a user update page, "EditUser.page" which uses the same 
> "UserNameElements.jwc" component.
>
> The first and last name, are required elements in the 
> "UserNameElements.jwc", however, I find I'm having to define the 
> "required" bean, and my form "delegate" bean in both the 
> "RegisterUser.page" and in the "EditUser.page".
>
> Since only the "UserNameElements.jwc" use the "required" and 
> "delegate" beans (in this simple example), isn't there somewhere I can 
> define those, perhaps in the "UserNameElements.jwc" ?
>
> Thanks all,
> tappapp
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org