Package javax.faces.component.behavior

Examples of javax.faces.component.behavior.ClientBehavior


                        writer.write(",");

                    writer.write(eventName + ":");
                    writer.write("function(ext) {");
                    for(Iterator<ClientBehavior> behaviorIter = eventBehaviors.iterator(); behaviorIter.hasNext();) {
                        ClientBehavior behavior = behaviorIter.next();
                        ClientBehaviorContext cbc = ClientBehaviorContext.createClientBehaviorContext(context, (UIComponent) component, eventName, clientId, params);
                        String script = behavior.getScript(cbc);

                        if(script != null) {
                            writer.write(script);
                        }
                    }
View Full Code Here


            } else {
               params = Collections.emptyList();
            }

            for (int i = 0; i < behaviors.size(); i++) {
                ClientBehavior behavior = behaviors.get(i);
                ClientBehaviorContext cbc = ClientBehaviorContext.createClientBehaviorContext(context, component, event, clientId, params);
                String script = behavior.getScript(cbc);

                if(script != null)
                    sb.append(script).append(";");
            }
        }
View Full Code Here

    private void restoreBehaviors(FacesContext ctx, List<ClientBehavior> existingBehaviors, Object[] state) {

        // this method assumes a one to one correspondence in both length and
        // order.
        for (int i = 0, len = state.length; i < len; i++) {
            ClientBehavior behavior = existingBehaviors.get(i);
            if (state[i] == null) {
                // nothing to do...move on
                continue;
            }
            // if the Behavior is a StateHolder, invoke restoreState
View Full Code Here

                }
            }

            // We only add the
            if (shouldAddBehavior(behaviorHolder, eventName)) {
                ClientBehavior behavior = createBehavior(context);
                behaviorHolder.addClientBehavior(eventName, behavior);
            }

        }
View Full Code Here

            // component libraries can provide own implementation
            if (eventBehaviors instanceof RandomAccess)
            {
                for (int i = 0, size = eventBehaviors.size(); i < size; i++)
                {
                    ClientBehavior behavior = eventBehaviors.get(i);
                    if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING))
                    {
                        return true;
                    }
                }
            }
            else
            {
                for (ClientBehavior behavior : eventBehaviors)
                {
                    if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING))
                    {
                        return true;
                    }
                }
            }
View Full Code Here

        RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
    }

    private ClientBehavior createClientBehavior(String handlerData, Set<ClientBehaviorHint> hints) {
        ClientBehavior behavior = facesEnvironment.createMock(ClientBehavior.class);
        expect(behavior.getScript(EasyMock.<ClientBehaviorContext>notNull())).andStubReturn(
                MessageFormat.format("prompt({0})", handlerData));

        expect(behavior.getHints()).andStubReturn(hints);
        return behavior;
    }
View Full Code Here

        componentAttributes.put("onclick", "alert(click)");

        Set<ClientBehaviorHint> emptyHintsSet = EnumSet.noneOf(ClientBehaviorHint.class);
        Set<ClientBehaviorHint> submittingHintsSet = EnumSet.of(ClientBehaviorHint.SUBMITTING);

        ClientBehavior keypressBehavior = createClientBehavior("keypress", emptyHintsSet);
        ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
        ClientBehavior actionBehavior2 = createClientBehavior("action2", submittingHintsSet);
        ClientBehavior actionBehavior3 = createClientBehavior("action3", emptyHintsSet);
        ClientBehavior contextmenuBehavior = createClientBehavior("contextmenu", emptyHintsSet);

        behaviorsMap.put("keypress", Arrays.asList(keypressBehavior));
        behaviorsMap.put("action", Arrays.asList(actionBehavior1, actionBehavior2, actionBehavior3));
        behaviorsMap.put("contextmenu", Arrays.asList(contextmenuBehavior));
View Full Code Here

        componentAttributes.put("onclick", "alert(click)");
        componentAttributes.put("style", "color:green");

        Set<ClientBehaviorHint> emptyHintsSet = EnumSet.noneOf(ClientBehaviorHint.class);

        ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
        behaviorsMap.put("action", Arrays.asList(actionBehavior1));

        ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
        UIComponent component = (UIComponent) behaviorHolder;
        return component;
View Full Code Here

        Map<String, String> requestParameterMap = new HashMap<String, String>();
        requestParameterMap.put(RenderKitUtils.BEHAVIOR_SOURCE_ID, behaviorSourceId);
        requestParameterMap.put(RenderKitUtils.BEHAVIOR_EVENT_NAME, behaviorEventName);
        expect(externalContext.getRequestParameterMap()).andStubReturn(requestParameterMap);

        ClientBehavior actionBehavior = createClientBehavior("action1", EnumSet.of(ClientBehaviorHint.SUBMITTING));
        ClientBehavior actionBehavior1 = createClientBehavior("action2", EnumSet.of(ClientBehaviorHint.SUBMITTING));
        behaviorsMap.put("action", Arrays.asList(actionBehavior, actionBehavior1));

        ClientBehavior blurBehavior = createClientBehavior("blur1", EnumSet.of(ClientBehaviorHint.SUBMITTING));
        behaviorsMap.put("blur", Arrays.asList(blurBehavior));

        return component;
    }
View Full Code Here

                    return;
                }
            }

            if (shouldAddBehavior(behaviorHolder, eventName)) {
                ClientBehavior behavior = createBehavior(context);

                behaviorHolder.addClientBehavior(eventName, behavior);
            }
        }
View Full Code Here

TOP

Related Classes of javax.faces.component.behavior.ClientBehavior

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.