에 자식으로 작업 명령 링크를 추가합니다 :어떻게 내 응용 프로그램에서 다음과 같은 사용자 지정 구성 요소를 구현 한 구성 요소
@FacesComponent ("org.app.component.hintBubble")
public class TutorialHintBubbleComponent extends UIComponentBase implements Serializable {
private static final long serialVersionUID = -8124906197708898894L;
public static final String COMPONENT_TYPE = "org.app.component.hintBubble";
@Override
public String getFamily() {
return COMPONENT_TYPE;
}
@Override
public boolean isTransient() {
return false;
}
@Override
public void encodeBegin(FacesContext context) throws IOException {
setId("hintBubble");
TutorialHintBubble value = (TutorialHintBubble) this.getValueExpression("value").getValue(context.getELContext());
ResponseWriter writer = context.getResponseWriter();
writer.startElement("div", this);
writer.writeAttribute("style", value.getCss().getBodyCss(), null);
writer.writeAttribute("class", "hint-bubble", null);
if (value.getPointer().getLocation() != HintBubblePoinerLocation.NONE) {
writer.startElement("div", this);
writer.writeAttribute("style", value.getCss().getPointerCss(), null);
writer.writeAttribute("class", "hint-bubble-pointer", null);
writer.endElement("div");
if (value.getBorder().getThicknessInPixels() > 0) {
writer.startElement("div", this);
writer.writeAttribute("style", value.getCss().getPointerBorderCss(), null);
writer.writeAttribute("class", "hint-bubble-pointer-border", null);
writer.endElement("div");
}
}
writer.startElement("div", this);
writer.writeAttribute("class", "hint-bubble-inner-html-container", null);
writer.write(value.getInnerHtml());
writer.endElement("div");
if (value.isShowConfirmButton()) {
writer.startElement("div", this);
writer.writeAttribute("class", "hint-bubble-btn-container", null);
UICommandLink commandLink = new UICommandLink();
getChildren().add(commandLink);
commandLink.setParent(this);
commandLink.setValue(value.getButtonCaption());
commandLink.setStyleClass("hint-bubble-btn");
commandLink.setId("okButton");
ValueExpression actionListenerExpression = getValueExpression("actionListener");
if (actionListenerExpression != null) {
commandLink.addActionListener(
(ActionListener) actionListenerExpression.getValue(context.getELContext())
);
}
}
}
@Override
public void encodeEnd(FacesContext context) throws IOException {
ResponseWriter writer = context.getResponseWriter();
TutorialHintBubble value = (TutorialHintBubble) this.getValueExpression("value").getValue(context.getELContext());
if (value.isShowConfirmButton()) {
writer.endElement("div");
}
writer.endElement("div");
}
}
당신이 UICommandLink이 구성 요소에 아이로서 추가가 볼 수 있듯이. 이 명령 링크에 첨부 된 것은 ActionListener입니다. ActionListener는 HintBubble 구성 요소에 매개 변수로 전달 된 표현식에서 평가됩니다. 디버깅은 동작 수신기가 올바르게 평가되어 UICommandLink에 추가되었음을 보여줍니다. XHTML에서
코드 :
<h:form id="tutorialForm">
<a4j:outputPanel id="tutorialContainer" layout="block" >
<a4j:repeat value="#{tutorialBean.hintBubbles}" var="hintBubble">
<gg:hintBubble value="#{hintBubble}" actionListener="#{tutorialManager}" />
</a4j:repeat>
</a4j:outputPanel>
</h:form>
모두가 제대로 웹 페이지에 렌더링하지만 클릭하면 버튼의 작업이 수행되지 않습니다. (아약스 요청이 서버로 전송되어 있지만)
내 질문은 :
하는 방법에서 나는 작업 물건을 얻기 위해 컴퍼넌트의 아이에 UICommandLink를 추가해야합니까? (UICommandLink는 richfaces, 즉 org.richfaces.component.UICommandLink 임).