We can use the "ui:remove" tag to define the content you want to remove.
By using the "ui:remove" tag we can think the tags wrapped by "ui:remove" tag is commented out
<ui:remove> <h:commandButton type="button" value="#{msg.buttonLabel}" /> </ui:remove>
becomes
<!-- <h:commandButton type="button" value="#{msg.buttonLabel}" /> </ui:remove> -->
The following code shows how to use the ui:remove tag.
The following code is from demo.xhtml.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:body> <ui:remove> <h:commandButton type="button" value="#{msg.buttonLabel}" /> </ui:remove> </h:body> </html>
The following code is from UserBean.java.
package com.java2s.common; import java.io.Serializable; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; @ManagedBean(name="msg") @SessionScoped public class UserBean implements Serializable{ String buttonLabel = "Submit"; public String getButtonLabel() { return buttonLabel; } public void setButtonLabel(String buttonLabel) { this.buttonLabel = buttonLabel; } }
Copy the generated WAR file from the target folder to Tomcat deployment folder and run Tomcat-Install-folder/bin/startup.bat.
After Tomcat finish starting, type the following URL in the browser address bar.
http://localhost:8080/simple-webapp/demo.xhtml