Search in sources :

Example 1 with ClientWindow

use of javax.faces.lifecycle.ClientWindow in project liferay-faces-bridge-impl by liferay.

the class BridgeRequestScopeCompat_2_2_Impl method saveClientWindow.

protected void saveClientWindow(ExternalContext externalContext) {
    ClientWindow clientWindow = externalContext.getClientWindow();
    Map<String, Object> requestMap = externalContext.getRequestMap();
    requestMap.put(BRIDGE_REQ_SCOPE_ATTR_CLIENT_WINDOW, clientWindow);
}
Also used : ClientWindow(javax.faces.lifecycle.ClientWindow)

Example 2 with ClientWindow

use of javax.faces.lifecycle.ClientWindow in project liferay-faces-bridge-impl by liferay.

the class BridgeRequestScopeCompat_2_2_Impl method restoreClientWindow.

protected void restoreClientWindow(ExternalContext externalContext) {
    Map<String, Object> requestMap = externalContext.getRequestMap();
    ClientWindow clientWindow = (ClientWindow) requestMap.remove(BRIDGE_REQ_SCOPE_ATTR_CLIENT_WINDOW);
    externalContext.setClientWindow(clientWindow);
}
Also used : ClientWindow(javax.faces.lifecycle.ClientWindow)

Example 3 with ClientWindow

use of javax.faces.lifecycle.ClientWindow in project liferay-faces-bridge-impl by liferay.

the class Tests method clientWindowTest.

// Test 6.162
@BridgeTest(test = "clientWindowTest")
public String clientWindowTest(TestBean testBean) {
    testBean.setTestComplete(true);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    ClientWindow origClientWindow = externalContext.getClientWindow();
    ClientWindow clientWindow = new ClientWindowTCKImpl(origClientWindow);
    externalContext.setClientWindow(clientWindow);
    if (clientWindow.equals(externalContext.getClientWindow())) {
        testBean.setTestResult(true, "externalContext.getClientWindow() correctly returned the same value that was passed to ExternalContext.setClientWindow(ClientWindow).");
    } else {
        testBean.setTestResult(false, "externalContext.getClientWindow() incorrectly returned a different value than was passed to ExternalContext.setClientWindow(ClientWindow).");
    }
    externalContext.setClientWindow(origClientWindow);
    if (testBean.getTestStatus()) {
        return Constants.TEST_SUCCESS;
    } else {
        return Constants.TEST_FAILED;
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) ClientWindow(javax.faces.lifecycle.ClientWindow) BridgeTest(com.liferay.faces.bridge.tck.annotation.BridgeTest)

Example 4 with ClientWindow

use of javax.faces.lifecycle.ClientWindow in project primefaces by primefaces.

the class OutcomeTargetRenderer method getTargetURL.

protected String getTargetURL(FacesContext context, UIOutcomeTarget outcomeTarget) {
    String url;
    boolean clientWindowRenderingModeEnabled = false;
    Object clientWindow = null;
    try {
        if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isAtLeastJsf22() && outcomeTarget.isDisableClientWindow()) {
            clientWindow = context.getExternalContext().getClientWindow();
            if (clientWindow != null) {
                clientWindowRenderingModeEnabled = ((ClientWindow) clientWindow).isClientWindowRenderModeEnabled(context);
                if (clientWindowRenderingModeEnabled) {
                    ((ClientWindow) clientWindow).disableClientWindowRenderMode(context);
                }
            }
        }
        String href = outcomeTarget.getHref();
        if (href != null) {
            url = "#".equals(href) ? "#" : context.getExternalContext().encodeRedirectURL(href, outcomeTarget.getParams());
        } else {
            NavigationCase navCase = findNavigationCase(context, outcomeTarget);
            if (navCase == null) {
                throw new FacesException("Could not resolve NavigationCase for outcome: " + outcomeTarget.getOutcome());
            }
            String toViewId = navCase.getToViewId(context);
            boolean isIncludeViewParams = isIncludeViewParams(outcomeTarget, navCase);
            Map<String, List<String>> params = getParams(context, navCase, outcomeTarget);
            if (params == null) {
                params = Collections.emptyMap();
            }
            url = context.getApplication().getViewHandler().getBookmarkableURL(context, toViewId, params, isIncludeViewParams);
            if (outcomeTarget.getFragment() != null) {
                url += "#" + outcomeTarget.getFragment();
            }
        }
    } finally {
        if (clientWindowRenderingModeEnabled && clientWindow != null) {
            ((ClientWindow) clientWindow).enableClientWindowRenderMode(context);
        }
    }
    return url;
}
Also used : NavigationCase(javax.faces.application.NavigationCase) ClientWindow(javax.faces.lifecycle.ClientWindow) FacesException(javax.faces.FacesException)

Example 5 with ClientWindow

use of javax.faces.lifecycle.ClientWindow in project primefaces by primefaces.

the class ClientWindow001 method submit.

public void submit() {
    ClientWindow clientWindow = FacesContext.getCurrentInstance().getExternalContext().getClientWindow();
    FacesMessage msg = new FacesMessage("jfwid", clientWindow.getId());
    FacesContext.getCurrentInstance().addMessage(null, msg);
}
Also used : ClientWindow(javax.faces.lifecycle.ClientWindow) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

ClientWindow (javax.faces.lifecycle.ClientWindow)7 BridgeTest (com.liferay.faces.bridge.tck.annotation.BridgeTest)1 FacesException (javax.faces.FacesException)1 FacesMessage (javax.faces.application.FacesMessage)1 NavigationCase (javax.faces.application.NavigationCase)1 ProjectStage (javax.faces.application.ProjectStage)1 ExternalContext (javax.faces.context.ExternalContext)1 FacesContext (javax.faces.context.FacesContext)1 Cookie (javax.servlet.http.Cookie)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 PrimeClientWindow (org.primefaces.clientwindow.PrimeClientWindow)1