custom component - why action binding not working?!!!!
Hi All
I encode an "HtmlCommandButton" within my custom renderer (see code excerpts, below)
Then, I try to connect (i.e., "bind") an "action" method in the backing bean to this button (i.e., "doAction()).
However, this method binding doesn't seem to work since the "doAction()" method in the backing bean (Jsp1Bean) never gets called!!
What more is required to to cause the action/binding mechanism to work properly for this button?
Thankyou for any help on this!!!
sd
***jsp1.jsp***
-
-
-
<f:view>
<h:form id="form01">
<my:myComponent id="myComponent01" />
</h:form>
</f:view>
-
-
-
***Jsp1Bean***
-
-
-
//the method in the backing bean (for binding the "commandButton" to)...
public String doAction()
{
return"actionDone";
}
//the above method is not being called...why?...
-
-
-
***MyRenderer***
-
-
-
//create a "div" (label).... clicking on this label should cause the "commandButton" to be clicked...
writer.startElement("div",component);
writer.writeAttribute("onclick","javascript: document.getElementById('commandButton').click();",null);
writer.writeText("click on this div to test",null);
writer.endElement("div");
//this is the "commandButton"...
writer.startElement("div",component);
//create the commandButton...
HtmlCommandButton commandButton = (HtmlCommandButton) context.getApplication().createComponent(HtmlCommandButton.COMPONENT_TYPE);
ApplicationFactory factory = (ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
MethodBinding methodBinding = factory.getApplication().createMethodBinding("#{jsp1Bean.doAction}",null);
commandButton.setAction(methodBinding);
commandButton.setOnclick("javascript: alert('you have successfully clicked the commandButton!...'); document.form01.submit();");
commandButton.setValue("commandButton");
commandButton.setId("commandButton");
//encode the "commandButton"...
commandButton.encodeBegin(context);
commandButton.encodeChildren(context);
commandButton.encodeEnd(context);
writer.endElement("div");
-
-
-
***faces-config.xml***
-
-
-
<navigation-rule>
<from-view-id>/jsp1.jsp</from-view-id>
<navigation-case>
<from-outcome>actionDone</from-outcome>
<to-view-id>/actionDone.jsp</to-view-id>
</navigation-case>
</navigation-rule>
-
-
-

