Avitesh Kesharwani
Avitesh Kesharwani

Reputation: 13

Not able to put url and actionListener together

I am new to JSF and UI. I want that when I click on submenu my business logic should execute and after that my page get renders. I tried below snippet but its not working, page is getting rendered but actionListener is not getting executed. when I remove the url part, the actionListener is working but now I am stuck like how to render the page.

<ace:menuItem id="RedactionCapture" value="Redaction"
    actionListener="#{redactionController.getRedactionList}"
    url="#{firmUtility.legalHoldCreationOrRemovalUrl}"
    style="width:220px" styleClass="dropdownmenu"
    target="imagepgframe">
</ace:menuItem>

Upvotes: 0

Views: 307

Answers (1)

Jasper de Vries
Jasper de Vries

Reputation: 20198

That is expected behavior. An actionListener is a listener for an action and not for a URL. You could create an action which does a redirect to the URL in combination with the listener or do all the work in the action. Please note that this not only the case in IceFaces, but also in PrimeFaces.

For example (with a listener), XHTML:

<ace:menuItem action="#{yourBean.redirect(firmUtility.legalHoldCreationOrRemovalUrl)}"
              actionListener="#{redactionController.getRedactionList}"
              ... />

Bean:

public void redirect(String url) throws IOException {
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    externalContext.redirect(url);
}

See also:

Upvotes: 2

Related Questions