You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Times2 <sa...@gmail.com> on 2011/10/19 17:03:03 UTC

Rendering Custom Component via Zone

Hi,

I have problem with replacing one custom component with another one via
AJAX, using zone component. Replacing first component with second should
happen on action inside first component. 
On parent page i have one block(with second component inside him) , zone
component and first component inside her(zone).

Event bubbling is working (method in the first component is invoking the
method in the parent page) but not as i was hopping to(it doesn't change the
first component with the second one).
 
Any help i can get is very much appreciated.  

Sorry for the wall of code.



//parent page

public class Index {

	@Property
	@InjectComponent
	private Zone loginzone;

	@Component
	private SignUp signUp;

	@Component
	private SignIn singin;

	@Inject
	private Block loginblock;

	public Block onProba() {
	
		
		return loginblock;
	}

}


Index.tml 

<html t:type="layout" title="com.faks.kab Index"
	xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
	
	<t:zone t:id="loginZone" id="zone">
		<div t:type="SignIn" t:id="singin" zone="zone"/>
	</t:zone>

	<t:block t:id="loginblock">
		<div t:type="SignUp" t:id="signup" />
	</t:block>


</html>


SignIn.tml

<t:container 
xmlns:p="tapestry:parameter"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
	<t:form t:id="signinform" t:zone="prop:zone">

		<input type="submit" value="Login" />
	</t:form>

</t:container>


//first component

SignIn.java

public class SignIn {

	@Inject
	private ComponentResources componentResources;

	@Component
	private Form signinform;

	@Parameter(defaultPrefix = BindingConstants.LITERAL)
	@Property
	@SuppressWarnings("unused")
	private String zone;

           boolean onSuccessFromSignInForm() { 

	 componentResources.triggerEvent("proba", null, callback);

	 return false;
	 
	  }
	 
	  
	private ComponentEventCallback callback = new ComponentEventCallback() {

		public boolean handleResult(Object result) {
			if(!(result instanceof Block)){
	
				return true;
			}
			return false;
		}
	};

Best regards


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Rendering-Custom-Component-via-Zone-tp4918130p4918130.html
Sent from the Tapestry - User 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: Rendering Custom Component via Zone

Posted by Times2 <sa...@gmail.com>.
Thiago H de Paula Figueiredo wrote:
> 
> 
> You're triggering your own event here, so what happens after your handler  
> method is exactly what you put inside your implementation of the  
> ComponentEventcallback's handleResult() method. Try @Inject'ing into your  
> component class ComponentEventResultProcessor and using its  
> processResultValue() method passing the Block instance you've received.
> 
> 
> 


Thanks a lot, that worked. I have injected
ComponentEventResultProcessor("AjaxComponentEventResultProcessor"
implementation)

@InjectService("AjaxComponentEventResultProcessor")
	private ComponentEventResultProcessor<Block> componentEventResultProcessor;

 and wrapped it via ComponentResultProcessorWrapper

private ComponentResultProcessorWrapper callback = new
ComponentResultProcessorWrapper(componentEventResultProcessor);

boolean onSuccessFromSignInForm() {
componentResources.triggerEvent("DesiredMethodName", null, callback);
}



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Rendering-Custom-Component-via-Zone-tp4918130p4925552.html
Sent from the Tapestry - User 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