Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

setActionListener on a4j:support does not execute the bean method

843844Nov 26 2008 — edited Nov 25 2009
Hi,
I have been trying to execute setActionListener method of HtmlAjaxSupport programatically. I can see that AJAX call is getting submitted to server, but somehow the method binding I have for setActionListener is not getting invoked. I am getting nuts for it. Please help me. Here is the code snippet I am using
public void includeCheckBox(FacesContext context, int rowIndex) throws IOException {
        HtmlSelectBooleanCheckbox checkBox = new HtmlSelectBooleanCheckbox();
        checkBox.setId("checkBox_" + rowIndex);
        HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();
        ajaxSupport.setEvent("onchange");
        ajaxSupport.setReRender(getJSFComponentId(context, "checkBox_" + rowIndex, "reportCube"));
        ajaxSupport.setActionListener(FacesContext.getCurrentInstance().getApplication().createMetho
dBinding("#{xmlolapReportBean.addPivotRow}", new Class[]{ActionEvent.class}));
        checkBox.getChildren().add(ajaxSupport);
        checkBox.setParent(this);
        RendererUtils.renderChild(context, checkBox);
    }
Here are the helper methods
   public String getJSFComponentId(FacesContext context, String id, String parentId) {
        return getJSFComponentPrefix(context, parentId) + id;
    }

    public String getJSFComponentPrefix(FacesContext context, String parentId) {
        int parentIdIndex = getClientId(context).indexOf(parentId);
        if (parentIdIndex == -1) {
            throw new RuntimeException("No parent id found for the component.");
        }
        return getClientId(context).substring(0, parentIdIndex);
    }
And here is the bean's method I have bound to setActionListener
public void addPivotRow(ActionEvent event) {
        System.out.println("Hello ActionListener. I got you. Hurray!!!");
    }
I am not able to execute this addPivotRow method when the checkBox's onchange event is called although the browser makes an Ajax request to server. I have verified it using firebug.

Also please let me know how can I get setReRenderMethod work using this programatic approach instead of usual jsp tag approach.

Thanks
Ahsan

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 23 2009
Added on Nov 26 2008
4 comments
218 views