Search in sources :

Example 1 with MultiZoneUpdate

use of org.apache.tapestry5.ajax.MultiZoneUpdate in project tapestry-5 by apache.

the class MultiZoneUpdateInsideForm method onValueChangedFromSelectValue1.

@Log
public Object onValueChangedFromSelectValue1(SelectObj selectObj, Integer integer, RetentionPolicy retentionPolicy) {
    final String suffix = String.format(", number %03d, retention policy %s", integer, retentionPolicy);
    List<SelectObj> select2List = new ArrayList();
    select2List.add(new SelectObj(4, "4 post ajax" + suffix));
    select2List.add(new SelectObj(5, "5 post ajax" + suffix));
    select2List.add(new SelectObj(6, "6 post ajax" + suffix));
    select2List.add(new SelectObj(7, "7 post ajax" + suffix));
    select2Model = new SelectObjModel(select2List);
    if (request.isXHR()) {
        return new MultiZoneUpdate("select1ValueZone", select1ValueZone.getBody()).add("select2ValueZone", select2ValueZone.getBody());
    } else {
        return this;
    }
}
Also used : MultiZoneUpdate(org.apache.tapestry5.ajax.MultiZoneUpdate) ArrayList(java.util.ArrayList) Log(org.apache.tapestry5.annotations.Log)

Example 2 with MultiZoneUpdate

use of org.apache.tapestry5.ajax.MultiZoneUpdate in project tapestry-5 by apache.

the class MultiZoneUpdateEventResultProcessor method processResultValue.

public void processResultValue(final MultiZoneUpdate value) throws IOException {
    Map<String, Object> map = value.getZoneToRenderMap();
    for (String zoneId : map.keySet()) {
        Object provided = map.get(zoneId);
        // The AjaxResponseRenderer will convert the object to a RenderCommand, but does nothing special if there's a failure
        // (because the stack trace will clearly identify what's going on). We do the conversion here so that we can relate
        // a failure to a zone id. It will just be a pass-thru on the second type coercion.
        RenderCommand zoneRenderCommand = toRenderer(zoneId, provided);
        ajaxResponseRenderer.addRender(zoneId, zoneRenderCommand);
    }
    // This is actually executed deferred:
    partialRenderer.renderPartialPageMarkup();
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand)

Example 3 with MultiZoneUpdate

use of org.apache.tapestry5.ajax.MultiZoneUpdate in project tapestry-5 by apache.

the class MultiZoneUpdateDemo method onActionFromUpdate.

Object onActionFromUpdate() {
    wilmaMessage = "His Wife, Wilma.";
    // Do one the new way
    ajaxResponseRenderer.addRender("fred", fredBlock);
    ajaxResponseRenderer.addCallback(new JavaScriptCallback() {

        public void run(JavaScriptSupport javascriptSupport) {
            javascriptSupport.require("app/multi-zone-update").with("message", "Updated");
        }
    });
    return new MultiZoneUpdate("barney", barneyBlock).add("dino", "His dog, Dino.").add(wilmaZone);
}
Also used : JavaScriptSupport(org.apache.tapestry5.services.javascript.JavaScriptSupport) MultiZoneUpdate(org.apache.tapestry5.ajax.MultiZoneUpdate) JavaScriptCallback(org.apache.tapestry5.services.ajax.JavaScriptCallback)

Aggregations

MultiZoneUpdate (org.apache.tapestry5.ajax.MultiZoneUpdate)2 ArrayList (java.util.ArrayList)1 Log (org.apache.tapestry5.annotations.Log)1 RenderCommand (org.apache.tapestry5.runtime.RenderCommand)1 JavaScriptCallback (org.apache.tapestry5.services.ajax.JavaScriptCallback)1 JavaScriptSupport (org.apache.tapestry5.services.javascript.JavaScriptSupport)1