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"));
}
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"));
}
Aggregations