Re: Changing a components property at runtime

2008-05-13 Thread Chris Lewis
Toby,

Components are just POJOs - as far as your application code they have no
common type; no common interface for such actions. There is a common
interface but it is fitted onto component classes at runtime. If you
need to set properties/call methods, you must provide such interfaces.

chris

Toby Hobson wrote:
 This may sound like a simple question but I can't work out how to change a 
 property programatically. Basically I'd like to disable a component from an 
 event handler. I know I can pass params in via TML or using annotations but I 
 can't find any setX() methods on the components

 Thanks 

 Toby


   

-- 
http://thegodcode.net


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



Re: Changing a components property at runtime

2008-05-13 Thread Toby Hobson
Thanks Chris,

Does this mean that there is no easy way to disable a textfield at runtime for 
instance? Would a mixin work for this?

Toby

- Original Message 
From: Chris Lewis [EMAIL PROTECTED]
To: Tapestry users users@tapestry.apache.org
Sent: Tuesday, 13 May, 2008 7:10:16 PM
Subject: Re: Changing a components property at runtime

Toby,

Components are just POJOs - as far as your application code they have no
common type; no common interface for such actions. There is a common
interface but it is fitted onto component classes at runtime. If you
need to set properties/call methods, you must provide such interfaces.

chris

Toby Hobson wrote:
 This may sound like a simple question but I can't work out how to change a 
 property programatically. Basically I'd like to disable a component from an 
 event handler. I know I can pass params in via TML or using annotations but I 
 can't find any setX() methods on the components

 Thanks 

 Toby


   

-- 
http://thegodcode.net


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






Re: Changing a components property at runtime

2008-05-13 Thread Chris Lewis
I seems like you'd want to use the 'disabled' parameter as Robert
mentioned, which many components have. Perhaps your dynamic behavior
could be solved by storing a flag in a page property and then using
something like:

input t:type=textfield disabled=disabled value=username/

Where disabled would be a boolean page property.

Toby Hobson wrote:
 Thanks Chris,

 Does this mean that there is no easy way to disable a textfield at runtime 
 for instance? Would a mixin work for this?

 Toby

 - Original Message 
 From: Chris Lewis [EMAIL PROTECTED]
 To: Tapestry users users@tapestry.apache.org
 Sent: Tuesday, 13 May, 2008 7:10:16 PM
 Subject: Re: Changing a components property at runtime

 Toby,

 Components are just POJOs - as far as your application code they have no
 common type; no common interface for such actions. There is a common
 interface but it is fitted onto component classes at runtime. If you
 need to set properties/call methods, you must provide such interfaces.

 chris

 Toby Hobson wrote:
   
 This may sound like a simple question but I can't work out how to change a 
 property programatically. Basically I'd like to disable a component from an 
 event handler. I know I can pass params in via TML or using annotations but 
 I can't find any setX() methods on the components

 Thanks 

 Toby


   
 

   

-- 
http://thegodcode.net



Re: Changing a components property at runtime

2008-05-13 Thread Robert Zeigler
Chris correctly pointed out that classes are POJOs, but I'm guessing  
he thought you were referring to your own components.
But I think you're thinking about framework-provided components, where  
you don't have the easy ability to get/set properties.
First, for many of these properties, there used to be getters/setters,  
until the @Property annotation came along. So if you find a good use- 
case where 3rd party code has a valid need to get or set the property,  
file a jira for that property + component, and you should see the  
property added back in.


But if the property in question is also a component parameter (like  
disabled is for most (all?) of the framework form-field components),  
then the approach outlined in my previous e-mail (binding the  
disabled parameter to a property of your page or containing  
component) is the way to go.


Cheers,

Robert

On May 13, 2008, at 5/131:21 PM , Toby Hobson wrote:


Thanks Chris,

Does this mean that there is no easy way to disable a textfield at  
runtime for instance? Would a mixin work for this?


Toby

- Original Message 
From: Chris Lewis [EMAIL PROTECTED]
To: Tapestry users users@tapestry.apache.org
Sent: Tuesday, 13 May, 2008 7:10:16 PM
Subject: Re: Changing a components property at runtime

Toby,

Components are just POJOs - as far as your application code they  
have no

common type; no common interface for such actions. There is a common
interface but it is fitted onto component classes at runtime. If you
need to set properties/call methods, you must provide such interfaces.

chris

Toby Hobson wrote:
This may sound like a simple question but I can't work out how to  
change a property programatically. Basically I'd like to disable a  
component from an event handler. I know I can pass params in via  
TML or using annotations but I can't find any setX() methods on the  
components


Thanks

Toby





--
http://thegodcode.net


-
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: Changing a components property at runtime

2008-05-13 Thread Robert Zeigler

Is disabled a parameter for the component?
If so, then why not make the dynamic disabled a property of the  
parent component or page, and bind the component parameter to the  
parent property?


For example:

the component:
  @Parameter
   boolean disabled;
   ...

The page or component that contains the component:
@Component(parameters={disabled=disabled,...}
private SomeComponent comp;

@Property
@Persist
private boolean disabled;

public onActionFromSomewhere() {
return disabled=false;
}


On May 13, 2008, at 5/1312:58 PM , Toby Hobson wrote:

This may sound like a simple question but I can't work out how to  
change a property programatically. Basically I'd like to disable a  
component from an event handler. I know I can pass params in via TML  
or using annotations but I can't find any setX() methods on the  
components


Thanks

Toby




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



Re: Changing a components property at runtime

2008-05-13 Thread Toby Hobson
Yep, that makes sense - i was thinking that the parameter specified in the 
annotation was a literal, but it's a prop so that will work nicely

Thanks guys

- Original Message 
From: Robert Zeigler [EMAIL PROTECTED]
To: Tapestry users users@tapestry.apache.org
Sent: Tuesday, 13 May, 2008 7:16:53 PM
Subject: Re: Changing a components property at runtime

Is disabled a parameter for the component?
If so, then why not make the dynamic disabled a property of the  
parent component or page, and bind the component parameter to the  
parent property?

For example:

the component:
   @Parameter
boolean disabled;
...

The page or component that contains the component:
@Component(parameters={disabled=disabled,...}
private SomeComponent comp;

@Property
@Persist
private boolean disabled;

public onActionFromSomewhere() {
 return disabled=false;
}


On May 13, 2008, at 5/1312:58 PM , Toby Hobson wrote:

 This may sound like a simple question but I can't work out how to  
 change a property programatically. Basically I'd like to disable a  
 component from an event handler. I know I can pass params in via TML  
 or using annotations but I can't find any setX() methods on the  
 components

 Thanks

 Toby



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






Re: Changing a components property at runtime

2008-05-13 Thread Chris Lewis
I just realized I repeated Rob, so listen to him :-)

Chris Lewis wrote:
 I seems like you'd want to use the 'disabled' parameter as Robert
 mentioned, which many components have. Perhaps your dynamic behavior
 could be solved by storing a flag in a page property and then using
 something like:

 input t:type=textfield disabled=disabled value=username/

 Where disabled would be a boolean page property.

 Toby Hobson wrote:
   
 Thanks Chris,

 Does this mean that there is no easy way to disable a textfield at runtime 
 for instance? Would a mixin work for this?

 Toby

 - Original Message 
 From: Chris Lewis [EMAIL PROTECTED]
 To: Tapestry users users@tapestry.apache.org
 Sent: Tuesday, 13 May, 2008 7:10:16 PM
 Subject: Re: Changing a components property at runtime

 Toby,

 Components are just POJOs - as far as your application code they have no
 common type; no common interface for such actions. There is a common
 interface but it is fitted onto component classes at runtime. If you
 need to set properties/call methods, you must provide such interfaces.

 chris

 Toby Hobson wrote:
   
 
 This may sound like a simple question but I can't work out how to change a 
 property programatically. Basically I'd like to disable a component from an 
 event handler. I know I can pass params in via TML or using annotations but 
 I can't find any setX() methods on the components

 Thanks 

 Toby


   
 
   
   
 

   

-- 
http://thegodcode.net