Suggestion component using

4916 단어 자바htmlXHTML
자신 에 게 보 여 주 는 것:
suggestionDemo.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j" xmlns:s="http://richfaces.org/s">
	<h:form id="form1">
		<s:div>this is a suggestionBox example
	     <br />
	     input code: pref like X or 1,2,3;
	     <br />
	     input name: pref like   ;
	    </s:div>
		<br />
		<h:panelGrid columns="4">
			<h:outputText value="Code:" />
			<h:inputText value="" id="codeId" />
			<h:outputText value="Name:" />
			<h:inputText value="" id="nameId" />
		</h:panelGrid>
		<ui:include src="/common/suggestTemplate.xhtml">
			<ui:param name="height" value="150" />
			<ui:param name="width" value="150" />
			<ui:param name="renderedCodeId" value="codeId" />
			<ui:param name="renderedNameId" value="nameId" />
			<ui:param name="filedCode" value="CODE_ID" />
			<ui:param name="filedName" value="DESC_C" />
			<ui:param name="tableName" value="SC_CODE" />
			<ui:param name="showCode" value="#{rich:element('codeId')}" />
			<ui:param name="showName" value="#{rich:element('nameId')}" />
			<ui:param name="autoCompleteAction" value="#{suggestAction}" />
		</ui:include>
	</h:form>
</ui:composition>

suggestTemplate.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

	<h:panelGroup>
		<!-- select name show code -->
		<h:inputHidden value="#{filedCode}" binding="#{autoCompleteAction.filedCode}"/>
		<h:inputHidden value="#{filedName}" binding="#{autoCompleteAction.filedName}"/>
		<h:inputHidden value="#{tableName}" binding="#{autoCompleteAction.tableName}"/>
		<rich:suggestionbox height="#{height}" width="#{width}" var="_result"
			for="#{renderedCodeId}" id="suggestion"
			suggestionAction="#{autoCompleteAction.autocomplete}"
			nothingLabel="No data found" fetchValue="#{_result.showCode}"
			usingSuggestObjects="true" limitToList="true"  bypassUpdates="true"
			onobjectchange="#{showName}.value= #{rich:component('suggestion')}.getSelectedItems().pluck('showName')">
			<h:column>
				<h:outputLabel value="#{_result.showCode}"/>
			</h:column>
			<h:column>
				<h:outputLabel value="#{_result.showName}" />
			</h:column>
		</rich:suggestionbox>
		<!-- select data show name  -->
		<rich:suggestionbox height="#{height}" width="#{width}" var="_result"
			for="#{renderedNameId}" id="suggestion_name"
			suggestionAction="#{autoCompleteAction.autocomplete}"
			nothingLabel="No data found" fetchValue="#{_result.showName}"
			usingSuggestObjects="true" limitToList="true" bypassUpdates="true"
			onobjectchange="#{showCode}.value= #{rich:component('suggestion_name')}.getSelectedItems().pluck('showCode')">
			<h:column>
				<h:outputLabel value="#{_result.showCode} " />
			</h:column>
			<h:column>
				<h:outputLabel value="#{_result.showName}" />
			</h:column>
		</rich:suggestionbox>
	</h:panelGroup>
</ui:composition>


좋은 웹페이지 즐겨찾기