简体   繁体   中英

disable jsf tag

I need help disabling this link click without using javascript. So this is a on jsf page where the beans would set a variable to false then the cancel should not be pressable.

             <p:column style="width:14%; text-align: center;">  
                    <f:facet name="header">  
                        <b><h:outputText value="Action" />  </b>
                    </f:facet> 
                     <a href="cancel.xhtml?id=#{requestClass.requestID}">
                        <h:outputText value="Cancel" />  
                     </a>

                </p:column>  

Thanks in advance!

Update:

       <p:column style="width:14%; text-align: center;">  
                    <f:facet name="header">  
                        <b><h:outputText value="Action" />  </b>
                    </f:facet> 
                    <h:link disabled="#{requestBean.cancelledStatus}" 
         outcome="cancel.xhtml?id=#{requestClass.requestID}" value="Cancel">
                         <f:param name="id" value="#{requestClass.requestID}" />
                    </h:link>


                </p:column>  

that didn't actually disable the button when page is loaded even though status of request is cancelled

Update 2: this error showing when updated to following:

<h:commandButton value="Cancel" action="cancel.xhtml?id=#{requestClass.requestID}" 
 disabled="#{requestBean.cancelledStatus}">
                        <f:param name="id" value="#{requestClass.requestID}" />
                    </h:commandButton>

it says:

/pending.xhtml @86,150 action="cancel.xhtml?id=#{requestClass.requestID}" Not a Valid 
Method Expression: cancel.xhtml?id=#{requestClass.requestID}

Instead of using normal HTML tag <a> , you should use JSF's <h:link> . This tag has the attribute disable that can be used to disable the link. In you case, it should look like this:

<h:link disable="#{requestClass.disableCancelLink}" outcome="cancel" value="Cancel">
   <f:param name="id" value="#{requestClass.requestID}" />
</h:link>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM