Re: Treating a Component Like a Form Field

2008-10-09 Thread Thiago H. de Paula Figueiredo
Em Wed, 08 Oct 2008 16:26:30 -0300, Keith Bottner [EMAIL PROTECTED]  
escreveu:


Do you have an example of this working. I have been going around and  
around and have not been able to get this to work, so I was hoping there  
was some code you wouldn't mind sharing that demonstrates this working.


I've just wrote and tested this example. The User class is the one from  
Generic Authentication  
(www.arsmachina.com.br/project/genericauthentication) and it is a simple  
Java class.


public class UserChooser {

	// the prefix must be PROP, because it (prefix) must be read-write for  
this to work.

@Parameter(defaultPrefix = BindingConstants.PROP)
@Property
@SuppressWarnings(unused)
private User user;

@Inject
private SelectModelFactory selectModelFactory;

public SelectModel getModel() {
return ...;
}

}

UserChooser.tml:
t:container  
xmlns:t=http://tapestry.apache.org/schema/tapestry_5_0_0.xsd;

select t:type=Select t:model=model t:value=user
/select
/t:container

TestPage.java:

@Property
private User user;

@OnEvent(component = testForm, value = Form.SUCCESS)
public void test() {
System.out.println(user.getName());
}

TestPage.tml:

form t:type=Form t:id=testForm

label for=userUser/label
select t:type=UserChooser t:id=user t:user=user/
br /

input type=submit/

/form

I hope it helps. :)

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Treating a Component Like a Form Field

2008-10-08 Thread Blower, Andy
Coincidentally we're having the same issues where we're trying to create 
reusable sections of forms as components that we'll use on lots of different 
forms. The information from these components is aggregated into a single value 
object which needs to get back into the parent page. For example, a date input 
component with day, month  year select boxes. The parent is only interested in 
a Date object which we want to be a bound parameter which works both ways.

The only way I've found to get this working so far is to inject the component 
and use a getter in the form submission event handler. Binding a parameter 
doesn't seem to work, because the properties updated within the component are 
not bound parameters and the bound parameter is never updated directly. I could 
update it for each of the properties, but I don't really want to do this as 
many times as I have properties that make up the single value object parameter. 
If the order that the properties are updated is predictable in some way, I 
could make the last setter called update the parameter.

I hope this makes sense, and makes the crux of this issue clear.

Andy.

 -Original Message-
 From: Jonathan Barker [mailto:[EMAIL PROTECTED]
 Sent: 07 October 2008 21:18
 To: 'Tapestry users'
 Subject: RE: Treating a Component Like a Form Field


 Yup, completely.

 This is just an issue of getting @Parameter working properly then.  I
 defer
 to Thiago.

 Jonathan


  -Original Message-
  From: Keith Bottner [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, October 07, 2008 15:42
  To: Tapestry users
  Subject: Re: Treating a Component Like a Form Field
 
  Jonathan,
 
  Actually I use an underlying select with an Encoder, OptionModel and
  SelectionModel, I just wrap it all into a single component because it
  gets used in a number of places and it is easier to set the Encoder,
  OptionModel and SelectionModel once then to have multiple developers
  remember what to set each time they want a select control with a list
  of countries.
 
  Make sense?
 
 
  On Oct 7, 2008, at 2:40 PM, Jonathan Barker wrote:
 
   Keith,
  
   Is there a particular reason that you created a custom component
 for
   the
   Country selection rather than just using the standard Select
   component?  Is
   it just that it gets used in a number of places, or was there
 another
   reason?
  
   Jonathan
  
  
   -Original Message-
   From: Keith Bottner [mailto:[EMAIL PROTECTED]
   Sent: Tuesday, October 07, 2008 14:59
   To: Tapestry users
   Subject: Re: Treating a Component Like a Form Field
  
   I have used @Parameter before but never like this. I am unsure how
   this would work.
  
   Right now inside of my component I have a field named selection
 and I
   have a public getter and setter so that I can retrieve this value
   from
   within the page that is using the component. I also have a
 @Property
   private Country country in a page that uses the component along
   with a
   @Component( id = country ) private CountrySelect countrySelect.
   After submitting the form the only way to retrieve what the user
   selected in the select drop down is to do
   countrySelect.getSelection(). The country field that is in the
 field
   does not get field. What I would like is to be able to NOT include
   the
   CountrySelect and just use the @Property Country country like the
   standard form controls.
  
   With all of that said, I do not see how @Parameter will make a
   difference. Is there some other use then the standard use
 supplying a
   parameter in a component template?
  
   Keith
  
   On Oct 6, 2008, at 5:22 PM, Thiago H. de Paula Figueiredo wrote:
  
   Em Mon, 06 Oct 2008 18:03:13 -0300, Keith Bottner
   [EMAIL PROTECTED] escreveu:
  
   I created a custom component for displaying a selection list of
   countries. However, I have found that the only way for me to
   retrieve what the selection is from the component is to declare
 a
   @Component to that particular field and then request the value
   directly from the component. Is there no way to have a custom
   component act like a typical text field and have it assign the
   selection to a @Property without having to have a @Component
   designator?
  
   Have you tried adding a @Parameter to your component? This way,
 you
   could bind it to page property (or page property property and so
 on
   recursively).
  
   --
   Thiago H. de Paula Figueiredo
   Independent Java consultant, developer, and instructor
   Consultor, desenvolvedor e instrutor em Java
   http://www.arsmachina.com.br/thiago
  
   -
 
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
   --
 ---
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED

Re: Treating a Component Like a Form Field

2008-10-07 Thread Keith Bottner
I have used @Parameter before but never like this. I am unsure how  
this would work.


Right now inside of my component I have a field named selection and I  
have a public getter and setter so that I can retrieve this value from  
within the page that is using the component. I also have a @Property  
private Country country in a page that uses the component along with a  
@Component( id = country ) private CountrySelect countrySelect.  
After submitting the form the only way to retrieve what the user  
selected in the select drop down is to do  
countrySelect.getSelection(). The country field that is in the field  
does not get field. What I would like is to be able to NOT include the  
CountrySelect and just use the @Property Country country like the  
standard form controls.


With all of that said, I do not see how @Parameter will make a  
difference. Is there some other use then the standard use supplying a  
parameter in a component template?


Keith

On Oct 6, 2008, at 5:22 PM, Thiago H. de Paula Figueiredo wrote:

Em Mon, 06 Oct 2008 18:03:13 -0300, Keith Bottner  
[EMAIL PROTECTED] escreveu:


I created a custom component for displaying a selection list of  
countries. However, I have found that the only way for me to  
retrieve what the selection is from the component is to declare a  
@Component to that particular field and then request the value  
directly from the component. Is there no way to have a custom  
component act like a typical text field and have it assign the  
selection to a @Property without having to have a @Component  
designator?


Have you tried adding a @Parameter to your component? This way, you  
could bind it to page property (or page property property and so on  
recursively).


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Treating a Component Like a Form Field

2008-10-07 Thread Thiago H. de Paula Figueiredo
Em Tue, 07 Oct 2008 15:58:34 -0300, Keith Bottner [EMAIL PROTECTED]  
escreveu:


I have used @Parameter before but never like this. I am unsure how this  
would work.


When you set a field that is a parameter, the bound page property is also  
set. A parameter in Tapestry is not just an in parameter, it is an out  
parameter too.


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Treating a Component Like a Form Field

2008-10-07 Thread Jonathan Barker
Keith,

Is there a particular reason that you created a custom component for the
Country selection rather than just using the standard Select component?  Is
it just that it gets used in a number of places, or was there another
reason?

Jonathan


 -Original Message-
 From: Keith Bottner [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, October 07, 2008 14:59
 To: Tapestry users
 Subject: Re: Treating a Component Like a Form Field
 
 I have used @Parameter before but never like this. I am unsure how
 this would work.
 
 Right now inside of my component I have a field named selection and I
 have a public getter and setter so that I can retrieve this value from
 within the page that is using the component. I also have a @Property
 private Country country in a page that uses the component along with a
 @Component( id = country ) private CountrySelect countrySelect.
 After submitting the form the only way to retrieve what the user
 selected in the select drop down is to do
 countrySelect.getSelection(). The country field that is in the field
 does not get field. What I would like is to be able to NOT include the
 CountrySelect and just use the @Property Country country like the
 standard form controls.
 
 With all of that said, I do not see how @Parameter will make a
 difference. Is there some other use then the standard use supplying a
 parameter in a component template?
 
 Keith
 
 On Oct 6, 2008, at 5:22 PM, Thiago H. de Paula Figueiredo wrote:
 
  Em Mon, 06 Oct 2008 18:03:13 -0300, Keith Bottner
  [EMAIL PROTECTED] escreveu:
 
  I created a custom component for displaying a selection list of
  countries. However, I have found that the only way for me to
  retrieve what the selection is from the component is to declare a
  @Component to that particular field and then request the value
  directly from the component. Is there no way to have a custom
  component act like a typical text field and have it assign the
  selection to a @Property without having to have a @Component
  designator?
 
  Have you tried adding a @Parameter to your component? This way, you
  could bind it to page property (or page property property and so on
  recursively).
 
  --
  Thiago H. de Paula Figueiredo
  Independent Java consultant, developer, and instructor
  Consultor, desenvolvedor e instrutor em Java
  http://www.arsmachina.com.br/thiago
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Treating a Component Like a Form Field

2008-10-07 Thread Keith Bottner

Jonathan,

Actually I use an underlying select with an Encoder, OptionModel and  
SelectionModel, I just wrap it all into a single component because it  
gets used in a number of places and it is easier to set the Encoder,  
OptionModel and SelectionModel once then to have multiple developers  
remember what to set each time they want a select control with a list  
of countries.


Make sense?


On Oct 7, 2008, at 2:40 PM, Jonathan Barker wrote:


Keith,

Is there a particular reason that you created a custom component for  
the
Country selection rather than just using the standard Select  
component?  Is

it just that it gets used in a number of places, or was there another
reason?

Jonathan



-Original Message-
From: Keith Bottner [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 07, 2008 14:59
To: Tapestry users
Subject: Re: Treating a Component Like a Form Field

I have used @Parameter before but never like this. I am unsure how
this would work.

Right now inside of my component I have a field named selection and I
have a public getter and setter so that I can retrieve this value  
from

within the page that is using the component. I also have a @Property
private Country country in a page that uses the component along  
with a

@Component( id = country ) private CountrySelect countrySelect.
After submitting the form the only way to retrieve what the user
selected in the select drop down is to do
countrySelect.getSelection(). The country field that is in the field
does not get field. What I would like is to be able to NOT include  
the

CountrySelect and just use the @Property Country country like the
standard form controls.

With all of that said, I do not see how @Parameter will make a
difference. Is there some other use then the standard use supplying a
parameter in a component template?

Keith

On Oct 6, 2008, at 5:22 PM, Thiago H. de Paula Figueiredo wrote:


Em Mon, 06 Oct 2008 18:03:13 -0300, Keith Bottner
[EMAIL PROTECTED] escreveu:


I created a custom component for displaying a selection list of
countries. However, I have found that the only way for me to
retrieve what the selection is from the component is to declare a
@Component to that particular field and then request the value
directly from the component. Is there no way to have a custom
component act like a typical text field and have it assign the
selection to a @Property without having to have a @Component
designator?


Have you tried adding a @Parameter to your component? This way, you
could bind it to page property (or page property property and so on
recursively).

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Treating a Component Like a Form Field

2008-10-07 Thread Jonathan Barker

Yup, completely.

This is just an issue of getting @Parameter working properly then.  I defer
to Thiago.

Jonathan


 -Original Message-
 From: Keith Bottner [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, October 07, 2008 15:42
 To: Tapestry users
 Subject: Re: Treating a Component Like a Form Field
 
 Jonathan,
 
 Actually I use an underlying select with an Encoder, OptionModel and
 SelectionModel, I just wrap it all into a single component because it
 gets used in a number of places and it is easier to set the Encoder,
 OptionModel and SelectionModel once then to have multiple developers
 remember what to set each time they want a select control with a list
 of countries.
 
 Make sense?
 
 
 On Oct 7, 2008, at 2:40 PM, Jonathan Barker wrote:
 
  Keith,
 
  Is there a particular reason that you created a custom component for
  the
  Country selection rather than just using the standard Select
  component?  Is
  it just that it gets used in a number of places, or was there another
  reason?
 
  Jonathan
 
 
  -Original Message-
  From: Keith Bottner [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, October 07, 2008 14:59
  To: Tapestry users
  Subject: Re: Treating a Component Like a Form Field
 
  I have used @Parameter before but never like this. I am unsure how
  this would work.
 
  Right now inside of my component I have a field named selection and I
  have a public getter and setter so that I can retrieve this value
  from
  within the page that is using the component. I also have a @Property
  private Country country in a page that uses the component along
  with a
  @Component( id = country ) private CountrySelect countrySelect.
  After submitting the form the only way to retrieve what the user
  selected in the select drop down is to do
  countrySelect.getSelection(). The country field that is in the field
  does not get field. What I would like is to be able to NOT include
  the
  CountrySelect and just use the @Property Country country like the
  standard form controls.
 
  With all of that said, I do not see how @Parameter will make a
  difference. Is there some other use then the standard use supplying a
  parameter in a component template?
 
  Keith
 
  On Oct 6, 2008, at 5:22 PM, Thiago H. de Paula Figueiredo wrote:
 
  Em Mon, 06 Oct 2008 18:03:13 -0300, Keith Bottner
  [EMAIL PROTECTED] escreveu:
 
  I created a custom component for displaying a selection list of
  countries. However, I have found that the only way for me to
  retrieve what the selection is from the component is to declare a
  @Component to that particular field and then request the value
  directly from the component. Is there no way to have a custom
  component act like a typical text field and have it assign the
  selection to a @Property without having to have a @Component
  designator?
 
  Have you tried adding a @Parameter to your component? This way, you
  could bind it to page property (or page property property and so on
  recursively).
 
  --
  Thiago H. de Paula Figueiredo
  Independent Java consultant, developer, and instructor
  Consultor, desenvolvedor e instrutor em Java
  http://www.arsmachina.com.br/thiago
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Treating a Component Like a Form Field

2008-10-06 Thread Thiago H. de Paula Figueiredo
Em Mon, 06 Oct 2008 18:03:13 -0300, Keith Bottner [EMAIL PROTECTED]  
escreveu:


I created a custom component for displaying a selection list of  
countries. However, I have found that the only way for me to retrieve  
what the selection is from the component is to declare a @Component to  
that particular field and then request the value directly from the  
component. Is there no way to have a custom component act like a typical  
text field and have it assign the selection to a @Property without  
having to have a @Component designator?


Have you tried adding a @Parameter to your component? This way, you could  
bind it to page property (or page property property and so on recursively).


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]