Search in sources :

Example 1 with ClientBehaviorHint

use of jakarta.faces.component.behavior.ClientBehaviorHint in project myfaces by apache.

the class ClientBehaviorRendererUtilsTest method testBuildBehaviorChain.

public void testBuildBehaviorChain() {
    Map<String, List<ClientBehavior>> behaviors = new HashMap<String, List<ClientBehavior>>();
    // Map<String, String> params = new HashMap<String, String>();
    Collection<ClientBehaviorContext.Parameter> params = new ArrayList<ClientBehaviorContext.Parameter>();
    UIComponent component = new HtmlInputText();
    Assert.assertEquals("", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, component.getClientId(facesContext), ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, null, null));
    Assert.assertEquals("return faces.util.chain(document.getElementById('j_id__v_0'), event,'huhn', 'suppe');", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, component.getClientId(facesContext), ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, "huhn", "suppe"));
    ClientBehavior submittingBehavior = new ClientBehaviorBase() {

        @Override
        public String getScript(ClientBehaviorContext behaviorContext) {
            return "script()";
        }

        @Override
        public Set<ClientBehaviorHint> getHints() {
            return EnumSet.allOf(ClientBehaviorHint.class);
        }
    };
    behaviors.put(ClientBehaviorEvents.CLICK, Arrays.asList(submittingBehavior));
    Assert.assertEquals("faces.util.chain(document.getElementById('j_id__v_0'), event,'huhn', 'script()', 'suppe'); return false;", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, component.getClientId(facesContext), ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, "huhn", "suppe"));
}
Also used : UIComponent(jakarta.faces.component.UIComponent) HtmlInputText(jakarta.faces.component.html.HtmlInputText) ClientBehaviorContext(jakarta.faces.component.behavior.ClientBehaviorContext) ClientBehaviorBase(jakarta.faces.component.behavior.ClientBehaviorBase) ClientBehaviorHint(jakarta.faces.component.behavior.ClientBehaviorHint) ClientBehavior(jakarta.faces.component.behavior.ClientBehavior)

Example 2 with ClientBehaviorHint

use of jakarta.faces.component.behavior.ClientBehaviorHint in project myfaces by apache.

the class ClientBehaviorRendererUtilsTest method testBuildBehaviorChain2.

public void testBuildBehaviorChain2() {
    Map<String, List<ClientBehavior>> behaviors = new HashMap<String, List<ClientBehavior>>();
    // Map<String, String> params = new HashMap<String, String>();
    Collection<ClientBehaviorContext.Parameter> params = new ArrayList<ClientBehaviorContext.Parameter>();
    UIComponent component = new HtmlInputText();
    Assert.assertEquals("", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, null, null));
    Assert.assertEquals("return faces.util.chain(this, event,'huhn', 'suppe');", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, "huhn", "suppe"));
    ClientBehavior submittingBehavior = new ClientBehaviorBase() {

        @Override
        public String getScript(ClientBehaviorContext behaviorContext) {
            return "script()";
        }

        @Override
        public Set<ClientBehaviorHint> getHints() {
            return EnumSet.allOf(ClientBehaviorHint.class);
        }
    };
    behaviors.put(ClientBehaviorEvents.CLICK, Arrays.asList(submittingBehavior));
    Assert.assertEquals("faces.util.chain(this, event,'huhn', 'script()', 'suppe'); return false;", ClientBehaviorRendererUtils.buildBehaviorChain(facesContext, component, ClientBehaviorEvents.CLICK, params, ClientBehaviorEvents.ACTION, params, behaviors, "huhn", "suppe"));
}
Also used : UIComponent(jakarta.faces.component.UIComponent) HtmlInputText(jakarta.faces.component.html.HtmlInputText) ClientBehaviorContext(jakarta.faces.component.behavior.ClientBehaviorContext) ClientBehaviorBase(jakarta.faces.component.behavior.ClientBehaviorBase) ClientBehaviorHint(jakarta.faces.component.behavior.ClientBehaviorHint) ClientBehavior(jakarta.faces.component.behavior.ClientBehavior)

Aggregations

UIComponent (jakarta.faces.component.UIComponent)2 ClientBehavior (jakarta.faces.component.behavior.ClientBehavior)2 ClientBehaviorBase (jakarta.faces.component.behavior.ClientBehaviorBase)2 ClientBehaviorContext (jakarta.faces.component.behavior.ClientBehaviorContext)2 ClientBehaviorHint (jakarta.faces.component.behavior.ClientBehaviorHint)2 HtmlInputText (jakarta.faces.component.html.HtmlInputText)2