You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ppetrou <pe...@cypoz.com> on 2009/08/12 17:21:49 UTC

ck/OnEvent with Context

I am using the example documented here
http://www.chenillekit.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
and I can't get the context optional parameter to work. 

The relevant code is as follows
*******************
<input t:id="code" t:type="TextField" translate="string" validate="required" 
							t:mixins="autocomplete, ck/OnEvent"
            				event="change"
onCompleteCallback="onTextFieldCompleteFunction"
		                  	value="auxInvoicedItemUI?.code"
context="${myContext}"/>
*******************
public Object onChangeEvent(List<String> values){}
*******************
    public List<String> getMyContext()
    {
	List<String> list = new ArrayList<String>();
	list.add("code101XXX");
	list.add(String.valueOf(0));
	list.add("codeXXX");
	return list;	
    }
*******************
The problem is that the values parameter of onChangeEvent(List<String>
values)
always returns one value which is the value of
value="auxInvoicedItemUI?.code"

Is there anyway I can have the values parameter also containing the values
returned by getMyContext() method?

Petros



-- 
View this message in context: http://n2.nabble.com/ck-OnEvent-with-Context-tp3431473p3431473.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


Re: ck/OnEvent with Context

Posted by ppetrou <pe...@cypoz.com>.
Thanks Norman, 

You were right. I modified the onInternalEvent() method of
AbstractEventMixin.java and it worked. 
I copied both methods below
Thanks again for your help

OLD
*******************	
Object onInternalEvent()
	{
		String input = request.getParameter(PARAM_NAME);

		final Holder valueHolder = Holder.create();

		ComponentEventCallback callback = new ComponentEventCallback()
		{
			public boolean handleResult(Object result)
			{
				valueHolder.put(result);
				return true;
			}
		};

		resources.triggerEvent(getEventName(), new Object[]{input}, callback);

		return valueHolder.get();
	}
*******************

NEW
*******************    
Object onInternalEvent(List<String> context)
    {
	String input = request.getParameter(PARAM_NAME);

	final Holder valueHolder = Holder.create();

	ComponentEventCallback callback = new ComponentEventCallback()
	{
	    public boolean handleResult(Object result)
	    {
		valueHolder.put(result);
		return true;
	    }
	};
	Object[] callbackMethodParameters = new Object[context.size() + 1];
	callbackMethodParameters[0] = input;
	for(int i=1; i< context.size(); i++)
	{
	    callbackMethodParameters[i] = context.get(i-1);
	}
	
	resources.triggerEvent(getEventName(), callbackMethodParameters, callback);

	return valueHolder.get();
    }
*******************



Norman Franke wrote:
> 
> I've had a lot of issues with CK and contexts, in my case  
> InPlaceCheckbox. I basically copied the source and wrote my own. In  
> this case, the afterRender didn't use the context when creating the  
> link, this makes the context empty when the onAction fires. And CK's  
> AjaxCheckbox doesn't use a context at all, apparently. Perhaps the  
> same thing is happening with the OnEvent?
> 
> I've been meaning to submit some bugs on this, but have been so busy.  
> Another one, if anyone cares, is that the DateTimePicker fails  
> (JavaScript exception) if it's hidden (in a hidden DIV or  
> FormFragment.) This failure causes JavaScript processing to stop on  
> the page causing all sorts of problems.
> 
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
> 
> 
> 
> On Aug 12, 2009, at 11:21 AM, ppetrou wrote:
> 
>>
>> I am using the example documented here
>> http://www.chenillekit.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
>> and I can't get the context optional parameter to work.
>>
>> The relevant code is as follows
>> *******************
>> <input t:id="code" t:type="TextField" translate="string"  
>> validate="required"
>> 							t:mixins="autocomplete, ck/OnEvent"
>>            				event="change"
>> onCompleteCallback="onTextFieldCompleteFunction"
>> 		                  	value="auxInvoicedItemUI?.code"
>> context="${myContext}"/>
>> *******************
>> public Object onChangeEvent(List<String> values){}
>> *******************
>>    public List<String> getMyContext()
>>    {
>> 	List<String> list = new ArrayList<String>();
>> 	list.add("code101XXX");
>> 	list.add(String.valueOf(0));
>> 	list.add("codeXXX");
>> 	return list;	
>>    }
>> *******************
>> The problem is that the values parameter of onChangeEvent(List<String>
>> values)
>> always returns one value which is the value of
>> value="auxInvoicedItemUI?.code"
>>
>> Is there anyway I can have the values parameter also containing the  
>> values
>> returned by getMyContext() method?
>>
>> Petros
>>
>>
>>
>> -- 
>> View this message in context:
>> http://n2.nabble.com/ck-OnEvent-with-Context-tp3431473p3431473.html
>> Sent from the Tapestry Users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/ck-OnEvent-with-Context-tp3431473p3435146.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


Re: ck/OnEvent with Context

Posted by Norman Franke <no...@myasd.com>.
I've had a lot of issues with CK and contexts, in my case  
InPlaceCheckbox. I basically copied the source and wrote my own. In  
this case, the afterRender didn't use the context when creating the  
link, this makes the context empty when the onAction fires. And CK's  
AjaxCheckbox doesn't use a context at all, apparently. Perhaps the  
same thing is happening with the OnEvent?

I've been meaning to submit some bugs on this, but have been so busy.  
Another one, if anyone cares, is that the DateTimePicker fails  
(JavaScript exception) if it's hidden (in a hidden DIV or  
FormFragment.) This failure causes JavaScript processing to stop on  
the page causing all sorts of problems.

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Aug 12, 2009, at 11:21 AM, ppetrou wrote:

>
> I am using the example documented here
> http://www.chenillekit.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
> and I can't get the context optional parameter to work.
>
> The relevant code is as follows
> *******************
> <input t:id="code" t:type="TextField" translate="string"  
> validate="required"
> 							t:mixins="autocomplete, ck/OnEvent"
>            				event="change"
> onCompleteCallback="onTextFieldCompleteFunction"
> 		                  	value="auxInvoicedItemUI?.code"
> context="${myContext}"/>
> *******************
> public Object onChangeEvent(List<String> values){}
> *******************
>    public List<String> getMyContext()
>    {
> 	List<String> list = new ArrayList<String>();
> 	list.add("code101XXX");
> 	list.add(String.valueOf(0));
> 	list.add("codeXXX");
> 	return list;	
>    }
> *******************
> The problem is that the values parameter of onChangeEvent(List<String>
> values)
> always returns one value which is the value of
> value="auxInvoicedItemUI?.code"
>
> Is there anyway I can have the values parameter also containing the  
> values
> returned by getMyContext() method?
>
> Petros
>
>
>
> -- 
> View this message in context: http://n2.nabble.com/ck-OnEvent-with-Context-tp3431473p3431473.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>