인터넷에서 샘플을 찾았습니다 (IBM 사이트 http://www.ibm.com/developerworks/web/library/j-jsf2fu-0410/index.html#listing1). 일부 책에서는 JSF로 자동 완성 드롭 다운 목록을 작성할 수 있습니다. Google 검색 페이지에서와 마찬가지로. 이것의 요점은 복합 컴포넌트 페이지 사용에 있습니다.작업 자동 맞춤 구성 요소는 어떻게 작동합니까?
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="value" required="true"/>
<composite:attribute name="completionItems" required="true"/>
</composite:interface>
<!-- IMPLEMENATION -->
<composite:implementation>
<div id="#{cc.clientId}">
<h:outputScript library="javascript"
name="prototype-1.6.0.2.js" target="head"/>
<h:outputScript library="javascript"
name="autoComplete.js" target="head"/>
<h:inputText id="input" value="#{cc.attrs.value}"
onkeyup="com.corejsf.updateCompletionItems(this, event)"
onblur="com.corejsf.inputLostFocus(this)"
valueChangeListener="#{autocompleteListener.valueChanged}"/>
<h:selectOneListbox id="listbox" style="display: none"
valueChangeListener="#{autocompleteListener.completionItemSelected}">
<f:selectItems value="#{cc.attrs.completionItems}"/>
<f:ajax render="input"/>
</h:selectOneListbox>
<div>
</composite:implementation>
</ui:composition>
내 질문은 다음과 같습니다 : 매개 변수 밖으로 구성 태그 :
왜 우리가 UI를 사용 그것은처럼 보인다.
우리는 시간에 가지고가 : InputText]를이 두 라인 방법
public void valueChanged(ValueChangeEvent e)
을 가지고 백엔드 클래스를 통해 실현 valueChangeListener을 정의UIInput input = (UIInput) e.getSource(); UISelectOne listbox = (UISelectOne) input.findComponent("listbox");
하면 (UIInput) ID = "이름"과 e.get 소스 반환 구성 요소 InputText]를 . 가능한 다음 줄 UISelectOne listbox = (UISelectOne) input.findComponent ("listbox");
나는 당신이 문제가있는 것을 얻지 못한다. 'ui : composition'은 시작 태그이고, 결코 "parameters"를 취하지 않습니다. 복합 컴포넌트의 이름이 어떻게 될지 궁금하신 분은이 코드를 넣은 파일의 이름입니다. – mabi