You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bruno Santos <bi...@gmail.com> on 2009/08/26 16:10:46 UTC

getClientId returning null

Hi all,

My name is Bruno and I'm new to this mailing list and new to tapestry.

I've been banging my head hard and googling (probably been using wrong
keywords) for an answer for this, why is getClientId returning null,
isn't it suppose to return the client id? If it ain't, is there a
workaround?

Code:

    @InjectComponent
    private Select country;

	@OnEvent(component = "country", value = "change")
	public JSONObject onChangeOperatorEvent(String value) {
		...
JSONObject finalJsonObject = new JSONObject();
		finalJsonObject.put("clientId", country.getClientId());

		return finalJsonObject;
}


-----------------

					<select t:type="select" t:id="country" encoder="countryEncoder"
model="countryModel" t:mixins="ck/OnEvent" t:event="change"
t:onCompleteCallback="handleSelectAjaxRequest"/>


------------------

I tried with textfield also, same result. I guess @InjectComponent
isn't enough. Can someone help me clarify this?

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


Re: getClientId returning null

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 26 Aug 2009 11:10:46 -0300, Bruno Santos <bi...@gmail.com>  
escreveu:

> Hi all,

Hi!

> My name is Bruno and I'm new to this mailing list and new to tapestry.

Welcome!

> I've been banging my head hard and googling (probably been using wrong
> keywords) for an answer for this, why is getClientId returning null,
> isn't it suppose to return the client id? If it ain't, is there a
> workaround?

The clientId is generally set during rendering. In your case, you're  
trying to get it during an event handler.
Field components that subclass AbstractField (almost of the ones provided  
by Tapestry) have a clientId parameter, so you can provide your own id  
instead of letting Tapestry generate it for you. I guess this can solve  
your problem.

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

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


Re: getClientId returning null

Posted by Bruno Santos <bi...@gmail.com>.
Thanks for clarifying that.

> Pass the component's clientside id as a context parameter to your handler
> method.

Is there a way, server-side, i can map the clientside id context to
the component so i can know wich id is what? I'm asking this cause,
using your suggestion i would have to pass more than one client id
since i might have to load information on more than one component and
without that mapping i wouldn't know where to put the information.
Well, i guess i could try to send the name and id in context but that
seems too complicated.

Thiago's suggestion:
> Tapestry) have a clientId parameter, so you can provide your own id instead
> of letting Tapestry generate it for you. I guess this can solve your
> problem.
Doesn't solve the problem since, don't know why using
t:clientId="country" on the tag isn't working and the id is still
being generated. might be a conflict with some other component with
same id, i guess, although i don't see it.


On Wed, Aug 26, 2009 at 3:29 PM, Ulrich Stärk<ul...@spielviel.de> wrote:
> The problem here is that you are trying to access the component's clientId
> without the component being rendered (in your case from an XHR). The
> clientId is only accurate after the component has rendered itself. See
> http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/ClientElement.html
> Pass the component's clientside id as a context parameter to your handler
> method.
>
> Uli
>
> On 26.08.2009 16:10 schrieb Bruno Santos:
>>
>> Hi all,
>>
>> My name is Bruno and I'm new to this mailing list and new to tapestry.
>>
>> I've been banging my head hard and googling (probably been using wrong
>> keywords) for an answer for this, why is getClientId returning null,
>> isn't it suppose to return the client id? If it ain't, is there a
>> workaround?
>>
>> Code:
>>
>>    @InjectComponent
>>    private Select country;
>>
>>        @OnEvent(component = "country", value = "change")
>>        public JSONObject onChangeOperatorEvent(String value) {
>>                ...
>> JSONObject finalJsonObject = new JSONObject();
>>                finalJsonObject.put("clientId", country.getClientId());
>>
>>                return finalJsonObject;
>> }
>>
>>
>> -----------------
>>
>>                                        <select t:type="select"
>> t:id="country" encoder="countryEncoder"
>> model="countryModel" t:mixins="ck/OnEvent" t:event="change"
>> t:onCompleteCallback="handleSelectAjaxRequest"/>
>>
>>
>> ------------------
>>
>> I tried with textfield also, same result. I guess @InjectComponent
>> isn't enough. Can someone help me clarify this?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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


Re: getClientId returning null

Posted by Ulrich Stärk <ul...@spielviel.de>.
The problem here is that you are trying to access the component's clientId without the component 
being rendered (in your case from an XHR). The clientId is only accurate after the component has 
rendered itself. See 
http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/ClientElement.html
Pass the component's clientside id as a context parameter to your handler method.

Uli

On 26.08.2009 16:10 schrieb Bruno Santos:
> Hi all,
> 
> My name is Bruno and I'm new to this mailing list and new to tapestry.
> 
> I've been banging my head hard and googling (probably been using wrong
> keywords) for an answer for this, why is getClientId returning null,
> isn't it suppose to return the client id? If it ain't, is there a
> workaround?
> 
> Code:
> 
>     @InjectComponent
>     private Select country;
> 
> 	@OnEvent(component = "country", value = "change")
> 	public JSONObject onChangeOperatorEvent(String value) {
> 		...
> JSONObject finalJsonObject = new JSONObject();
> 		finalJsonObject.put("clientId", country.getClientId());
> 
> 		return finalJsonObject;
> }
> 
> 
> -----------------
> 
> 					<select t:type="select" t:id="country" encoder="countryEncoder"
> model="countryModel" t:mixins="ck/OnEvent" t:event="change"
> t:onCompleteCallback="handleSelectAjaxRequest"/>
> 
> 
> ------------------
> 
> I tried with textfield also, same result. I guess @InjectComponent
> isn't enough. Can someone help me clarify this?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

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