You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tapestry Infodea <ta...@infodea.it> on 2009/01/23 12:25:06 UTC

[T.5.0.18] FormSupportAdapter question

Hi guys,
I've implemented a new component that make AJAX call on a select change 
event and update the page with the AJAX response. The Ajax response is 
the result of a Block render. The Block contains a BeanEditor.

The following is a sample code portion of what I've done and some 
questions about the implementation:

void beginRender(MarkupWriter writer) {
  Link l = resources.createEventLink("SelectChange");
  renderSupport.addScript("new FieldObserve('%s');", l.toAbsoluteURI());
  componentActions = new ComponentActionSink(logger);
  formSupport = new FormSupportAdapter(formSupport) {
  @Override
  public <T> void store(T component, ComponentAction<T> action) {
	componentActions.store(component, action);
  }
  @Override
  public <T> void storeAndExecute(T component, ComponentAction<T> action)
  {
	componentActions.store(component, action);
	action.execute(component);
  }
  };
  environment.push(FormSupport.class, formSupport);
}

void afterRender(MarkupWriter writer) {
  environment.pop(FormSupport.class);
}


/*Ajax Call on select change. Returns a Block containing a BeanEditor.*/
Object onSelectChange() {
  environment.push(FormSupport.class, formSupport);
  environment.push(ValidationTracker.class, validationTracker);
  return getBlock(request.getParameter("value"));
}

The questions:

1)In the onSelectChange method the services FormSupport and 
ValidationTracker are not available in the environment's stack; 
therefore I have to add these services using two previously setted 
persisted (@Persist) variables.
Is there a better way to pass these services to my method?

2)In the method beginRender I must create a new FormSupportAdapter as 
like as FormFragment component otherwise the ComponentActionSink.store() 
method throws an IOException.
Have you any idea I have to create a FormSupportAdapter?

Grazie!

Roberto Iannone.

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