A在互聯網上找到了樣本(IBM站點http://www.ibm.com/developerworks/web/library/j-jsf2fu-0410/index.html#listing1),並且在某些書上使用JSF可以使自動完成下拉列表。喜歡在谷歌搜索頁面。這個主要點在使用複合組件頁面。它看起來像:如何工作自動complite自定義組件?
<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>
我的問題是:
爲什麼我們使用的用戶界面:成分標籤與任何參數。
我們在H:inputText的定義valueChangeListener,實現在其上具有方法
public void valueChanged(ValueChangeEvent e)
與這兩條線後端類UIInput input = (UIInput) e.getSource(); UISelectOne listbox = (UISelectOne) input.findComponent("listbox");
如果(UIInput)e.get源返回部件的inputText使用id = 「名稱」 。如何可能下一行 UISelectOne listbox =(UISelectOne)input.findComponent(「listbox」);
我不太明白你有什麼問題。 'ui:composition'是開始標記,它從不需要「參數」。如果您想知道如何命名複合組件,那麼您將此代碼放在該文件的名稱中。 – mabi
可以是
vmaric