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>

-

-

-

[3584 byte] By [flairn999a] at [2007-10-2 19:36:18]
# 1
Do you have jsp1Bean correctly configured in faces-config.xml?Do you have a h:messages on your page?
pringia at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I have <h:messages/>

tag...

Below is the managed-bean definition....

-

-

-

<managed-bean>

<managed-bean-name>jsp1Bean</managed-bean-name>

<managed-bean-class>xyz.Jsp1Bean</managed-bean-class>

<managed-bean-scope>request</managed-bean-scope>

</managed-bean>

-

-

-

flairn999a at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Try to remove the setOnclick Also do you have any renderResponse on your code?
pringia at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
I removed the setOnclick, but, this has no effect...Thanks
flairn999a at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Does a normal commandButton works on your page?Ie, not a custom component.
pringia at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Hi Pringi Yes, a "normal" commandButton does work.
flairn999a at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Ok. Try to invoke the action from this regular commandButton. Verify if works. Is so, then you must verify your custom component code
pringia at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

Hi Pringi

Ah, yes... this is the issue for me (i.e., "verify your custom component code )".

I dont know where to look first because I do not know what could be missing.

I have found no literature that specifically addresses the conventional code "wiring" (i.e., in the custom components-- particularly the "component", "renderer", "tag" java classes) that is required to attached, for example,a custom rendered button action to a corresponding backing bean method ("e.g., doAction()").

If you could provide guidance in this area, it would be much appreciated.

Thanks!!

flairn999a at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
I'm no custom component specialist...(At least for now) See this tutorial maybe it helps: http://jsftutorials.net/articles/actionLink.html
pringia at 2007-7-13 21:24:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...