6
버튼 그룹에 대해 아래에서 언급 한 복합 구성 요소를 사용하는 동안 "빈 ID 속성이 JSF에서 허용되지 않습니다"라는 문제가 발생했습니다 (나는 Mojarra 2-0-8을 Tomcat-7에서 사용한다.)JSF 컴포지트 구성 요소에서 빈 id 속성을 사용할 수 없습니다.
<?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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="buttonCount" />
<composite:attribute name="button1Id" />
<composite:attribute name="button1Style" />
<composite:attribute name="button1Action" />
<composite:attribute name="button2Id" />
<composite:attribute name="button2Style" />
<composite:attribute name="button2Action" />
<composite:attribute name="button3Id" />
<composite:attribute name="button3Style" />
<composite:attribute name="button3Action" />
</composite:interface>
<composite:implementation>
<h:commandButton rendered = "#{cc.attrs.buttonCount ge '1'}" id="#{cc.attrs.button1Id}" styleClass="#{cc.attrs.button1Style}">
<f:ajax listener="#{cc.attrs.button1Action}" immediate="true"/>
</h:commandButton>
<h:panelGroup rendered = "#{cc.attrs.buttonCount ge '2'}">
<h:commandButton id="#{cc.attrs.button2Id}" styleClass="#{cc.attrs.button2Style}">
<f:ajax listener="#{cc.attrs.button2Action}" immediate="true"/>
</h:commandButton>
</h:panelGroup>
<h:panelGroup rendered = "#{cc.attrs.buttonCount eq '3'}">
<h:commandButton id="#{cc.attrs.button3Id}" styleClass="#{cc.attrs.button3Style}">
<f:ajax listener="#{cc.attrs.button3Action}" immediate="true"/>
</h:commandButton>
</h:panelGroup>
</composite:implementation>
</html>
위의 CC의 사용.
<Buttons:myButton txtHeader="Title" txtDescription="text1"
txtAction="TextAction." button1Style="btnSave" buttonCount ="1" button1Id="btnSaveConf" button1Action="#{MyBean.save()}"></Buttons:myButton>
메인 페이지의 수 또는 모든 유사 입력을 기반으로 버튼을 동적으로 생성하는 더 좋은 방법은 없습니다. 참고 : - ID, 스타일 및 작업의 이름이 달라야합니다.