Start Execution in Foreign Ajax Channel"
From Documentation
Line 12: | Line 12: | ||
= Example = | = Example = | ||
− | + | == Start Execution in JSF 2 Client Behaviors == | |
− | |||
For example, with JSF 2, you could do as follows. | For example, with JSF 2, you could do as follows. | ||
Line 25: | Line 24: | ||
HttpServletResponse response = (HttpServletRersponse)ec.getResponse(); | HttpServletResponse response = (HttpServletRersponse)ec.getResponse(); | ||
− | + | Component comp = getComponent(); | |
Bridge bridge = Bridge.start(svlctx, request, response, comp.getDesktop()); | Bridge bridge = Bridge.start(svlctx, request, response, comp.getDesktop()); | ||
try { | try { |
Revision as of 05:02, 16 September 2010
Employment/Purpose
Here describes how to start a ZK execution in a foreign Ajax channel. For example, JSF 2 allows developers to send back JavaScript code to update the browser in JSF's Ajax channel[1].
- ↑ For more information, please refer to Introducing JSF 2 Client Behaviors
Example
Start Execution in JSF 2 Client Behaviors
For example, with JSF 2, you could do as follows.
<syntax lang="java"> public class MyCustomBehavior extends ClientBehaviorBase {
@Override public String getScript(ClientBehaviorContext bc) { ExternalContext ec = bc.getFacesContext().getExternalContext(); ServletContext svlctx = (ServletContext)ec.getContext(); HttpServletRequest request = (HttpServletRequest)ec.getRequest(); HttpServletResponse response = (HttpServletRersponse)ec.getResponse();
Component comp = getComponent(); Bridge bridge = Bridge.start(svlctx, request, response, comp.getDesktop()); try { //...do whatever you want comp.appendChild(new Label("custom behavior triggered")); return bridge.getResult(); } finally { bridge.close(); } } private Component getComponent() { //locate the component that you want to handle }
} </syntax>
Version History
Version | Date | Content |
---|---|---|
5.0.5 | September 2010 | Bridge was introduced to simplify the starting of an execution in foreign Ajax channel |