MovieList.xhtml 5.59 KB
<!DOCTYPE composition 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:s="http://jboss.com/products/seam/taglib"
	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:rich="http://richfaces.org/rich" template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form id="movieSearch" styleClass="edit">

			<rich:simpleTogglePanel label="Movie Search Filter" switchType="ajax">

				<s:decorate template="/layout/display.xhtml">
					<ui:define name="label">Director</ui:define>
					<h:inputText id="director" value="#{movieList.movie.director}" />
				</s:decorate>

				<s:decorate template="/layout/display.xhtml">
					<ui:define name="label">Title</ui:define>
					<h:inputText id="title" value="#{movieList.movie.title}" />
				</s:decorate>

				<s:decorate template="/layout/display.xhtml">
					<ui:define name="label">Match</ui:define>
					<h:selectOneRadio id="logic"
						value="#{movieList.restrictionLogicOperator}" styleClass="radio">
						<f:selectItem itemLabel="All" itemValue="and" />
						<f:selectItem itemLabel="Any" itemValue="or" />
					</h:selectOneRadio>
				</s:decorate>

			</rich:simpleTogglePanel>

			<div class="actionButtons">
				<h:commandButton id="search" value="Search" action="/view/example/MovieList.xhtml" /> 
				<s:button id="reset" value="Reset" includePageParams="false" />
			</div>

		</h:form>

		<rich:panel>
			<f:facet name="header">
				Movie Search Results (#{empty movieList.resultList ? 0 : (movieList.paginated ? movieList.resultCount : movieList.resultList.size)})
			</f:facet>
			
			<div class="results" id="movieList">
				<h:outputText
					value="The movie search returned no results."
					rendered="#{empty movieList.resultList}" /> <rich:dataTable
					id="movieList" var="_movie" value="#{movieList.resultList}"
					rendered="#{not empty movieList.resultList}">
					
				<h:column>
					<f:facet name="header">
						<ui:include src="/layout/sort.xhtml">
							<ui:param name="entityList" value="#{movieList}" />
							<ui:param name="propertyLabel" value="Id" />
							<ui:param name="propertyPath" value="movie.id" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_movie.id}" />
				</h:column>
				
				<h:column>
					<f:facet name="header">
						<ui:include src="/layout/sort.xhtml">
							<ui:param name="entityList" value="#{movieList}" />
							<ui:param name="propertyLabel" value="Director" />
							<ui:param name="propertyPath" value="movie.director" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_movie.director}" />
				</h:column>
				
				<h:column>
					<f:facet name="header">
						<ui:include src="/layout/sort.xhtml">
							<ui:param name="entityList" value="#{movieList}" />
							<ui:param name="propertyLabel" value="Title" />
							<ui:param name="propertyPath" value="movie.title" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_movie.title}" />
				</h:column>
				
				<h:column>
					<f:facet name="header">
						<ui:include src="/layout/sort.xhtml">
							<ui:param name="entityList" value="#{movieList}" />
							<ui:param name="propertyLabel" value="Year" />
							<ui:param name="propertyPath" value="movie.year" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_movie.year}" />
				</h:column>
				
				<h:column>
					<f:facet name="header">
						<ui:include src="/layout/sort.xhtml">
							<ui:param name="entityList" value="#{movieList}" />
							<ui:param name="propertyLabel" value="Plot" />
							<ui:param name="propertyPath" value="movie.plot" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_movie.plot}" />
				</h:column>
				
				<rich:column styleClass="action">
					<f:facet name="header">Action</f:facet>
					<s:link view="/view/example/#{empty from ? 'Movie' : from}.xhtml"
						value="#{empty from ? 'View' : 'Select'}"
						propagation="#{empty from ? 'none' : 'default'}" id="movieViewId">
						<f:param name="movieId" value="#{_movie.id}" />
					</s:link>
          #{' '}
          <s:link view="/view/example/MovieEdit.xhtml" value="Edit"
						propagation="none" id="movieEdit" rendered="#{empty from}">
						<f:param name="movieId" value="#{_movie.id}" />
					</s:link>
				</rich:column>
			</rich:dataTable></div>
		</rich:panel>

		<div class="tableControl">
			<s:link view="/view/example/MovieList.xhtml"
				rendered="#{movieList.previousExists}"
				value="#{messages.left}#{messages.left} First Page" id="firstPage">
				<f:param name="firstResult" value="0" />
			</s:link> 
			<s:link view="/view/example/MovieList.xhtml"
				rendered="#{movieList.previousExists}"
				value="#{messages.left} Previous Page" id="previousPage">
				<f:param name="firstResult" value="#{movieList.previousFirstResult}" />
			</s:link> 
			<s:link view="/view/example/MovieList.xhtml" rendered="#{movieList.nextExists}"
				value="Next Page #{messages.right}" id="nextPage">
				<f:param name="firstResult" value="#{movieList.nextFirstResult}" />
			</s:link> 
			<s:link view="/view/example/MovieList.xhtml" rendered="#{movieList.nextExists}"
				value="Last Page #{messages.right}#{messages.right}" id="lastPage">
				<f:param name="firstResult" value="#{movieList.lastFirstResult}" />
			</s:link>
		</div>

		<s:div styleClass="actionButtons" rendered="#{empty from}">
			<s:button view="/view/example/MovieEdit.xhtml" id="create" propagation="none"
				value="Create movie">
				<f:param name="movieId" />
			</s:button>
		</s:div>

	</ui:define>

</ui:composition>