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