1

In the following code snippet, 'Test Action 2' button executes but 'Test Action 1' button does not. How do I get 'Test Action 1' to execute?

I have verified that non of the points in hcommandlink-hcommandbutton-is-not-being-invoked apply.

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:shiro="http://shiro.apache.org/tags">
    <h:form>
        <h:messages />
        <c:if test="#{null ne requestScope['breadCrumbList']}">
            <div class="breadcrumb">
                <h:commandButton value="Test Action 1"
                    action="#{bcrumbCtrl.doStuff}"
                    actionListener="#{bcrumbCtrl.doStuff}" />
            </div>
        </c:if>
        <h:commandButton value="Test Action2" action="#{bcrumbCtrl.doStuff}"
            actionListener="#{bcrumbCtrl.doStuff}" />
    </h:form>
</ui:composition>
Community
  • 1
  • 1
jniyi
  • 11
  • 1
  • What is `requestScope['breadCrumbList']` supposed to be? is requestScope a MessageBundle? If it's supposed to be a managed bean, you should access it via something like `requestScopedBean.breadCrumbList` – noone Oct 23 '13 at 17:28
  • requestScope is the jsf request scope object. It is the same idiom as requestScope.breadCrumbList or requestScope.get('breadCrumbList') – jniyi Oct 23 '13 at 17:32
  • It seems like putting this List in a `@RequestScoped` managed bean would suit better here. – noone Oct 23 '13 at 17:35
  • What do you mean by *Test 1 doesn't execute*, it is not rendered in generated HTML or it is rendered but doesn't send the request to the server? – Luiggi Mendoza Oct 23 '13 at 17:35
  • 'Test Action 1' is rendered but the action method is not called – jniyi Oct 23 '13 at 17:39
  • @BalusC how do I implement point 5 of http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked/2120183#2120183. I am using CDI and all the scope objects are from the package javax.enterprise.context, so view scope is not available. How do I implement "preinitializing the condition in (post)constructor of the bean?" – jniyi Oct 24 '13 at 13:16
  • `` is not supposed to be able to affect the outcome of the `` because both tags are evaluated at different points in the life cycle (compile-time/build time). Try the button without the `` – kolossus Oct 25 '13 at 07:47
  • @kolossus I have used the rendered attribute and it gave the same result. I need to conditionally show a markup where 'Test button 2' is. I need a UICommand to be there too. But any UICommand I put there whether commandButton or commandLink does not execute. I think the problem is with the request scope but the breadcrumb object has to be stored in request scope. – jniyi Oct 25 '13 at 20:26

0 Answers0