blob: 744ffa53332ac8c9f70d426deecc5e315fd0fde9 [file] [log] [blame]
<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<#if comment>
TEMPLATE DESCRIPTION:
This is XHTML template for 'JSF Pages From Entity Beans' action. Templating
is performed using FreeMaker (http://freemarker.org/) - see its documentation
for full syntax. Variables available for templating are:
entityName - name of entity being modified (type: String)
managedBean - name of managed choosen in UI (type: String)
managedBeanProperty - name of managed bean property choosen in UI (type: String)
item - name of property used for dataTable iteration (type: String)
comment - always set to "false" (type: Boolean)
nsLocation - which namespace location to use (http://xmlns.jcp.org in case of JSF2.2, http://java.sun.com otherwise)
entityDescriptors - list of beans describing individual entities. Bean has following properties:
label - field label (type: String)
name - field property name (type: String)
dateTimeFormat - date/time/datetime formatting (type: String)
blob - does field represents a large block of text? (type: boolean)
relationshipOne - does field represent one to one or many to one relationship (type: boolean)
relationshipMany - does field represent one to many relationship (type: boolean)
returnType - fully qualified data type of the field (type: String)
id - field id name (type: String)
required - is field optional and nullable or it is not? (type: boolean)
valuesGetter - if item is of type 1:1 or 1:many relationship then use this
getter to populate <h:selectOneMenu> or <h:selectManyMenu>
bundle - name of the variable defined in the JSF config file for the resource bundle (type: String)
This template is accessible via top level menu Tools->Templates and can
be found in category JavaServer Faces->JSF from Entity.
</#if>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="${nsLocation}/jsf/facelets"
xmlns:h="${nsLocation}/jsf/html"
xmlns:f="${nsLocation}/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:composition>
<p:dialog id="${entityName}CreateDlg" widgetVar="${entityName}CreateDialog" modal="true" resizable="false" appendTo="@(body)" header="${r"#{"}${bundle}.Create${entityName}Title${r"}"}">
<h:form id="${entityName}CreateForm">
<h:panelGroup id="display">
<p:panelGrid columns="2" rendered="${r"#{"}${managedBeanProperty} != null${r"}"}">
<#list entityDescriptors as entityDescriptor>
<p:outputLabel value="${r"#{"}${bundle}.Create${entityName}Label_${entityDescriptor.id?replace(".","_")}${r"}"}" for="${entityDescriptor.id?replace(".","_")}" />
<#if entityDescriptor.dateTimeFormat?? && entityDescriptor.dateTimeFormat != "">
<p:calendar id="${entityDescriptor.id?replace(".","_")}" pattern="${entityDescriptor.dateTimeFormat}" value="${r"#{"}${entityDescriptor.name}${r"}"}" title="${r"#{"}${bundle}.Edit${entityName}Title_${entityDescriptor.id?replace(".","_")}${r"}"}" <#if entityDescriptor.required>required="true" requiredMessage="${r"#{"}${bundle}.Edit${entityName}RequiredMessage_${entityDescriptor.id?replace(".","_")}${r"}"}"</#if> showOn="button"/>
<#elseif entityDescriptor.returnType?matches(".*[Bb]+oolean")>
<p:selectBooleanCheckbox id="${entityDescriptor.id?replace(".","_")}" value="${r"#{"}${entityDescriptor.name}${r"}"}" <#if entityDescriptor.required>required="true" requiredMessage="${r"#{"}${bundle}.Edit${entityName}RequiredMessage_${entityDescriptor.id?replace(".","_")}${r"}"}"</#if>/>
<#elseif entityDescriptor.blob>
<p:inputTextarea rows="4" cols="30" id="${entityDescriptor.id?replace(".","_")}" value="${r"#{"}${entityDescriptor.name}${r"}"}" title="${r"#{"}${bundle}.Create${entityName}Title_${entityDescriptor.id?replace(".","_")}${r"}"}" <#if entityDescriptor.required>required="true" requiredMessage="${r"#{"}${bundle}.Create${entityName}RequiredMessage_${entityDescriptor.id?replace(".","_")}${r"}"}"</#if>/>
<#elseif entityDescriptor.relationshipOne>
<p:selectOneMenu id="${entityDescriptor.id?replace(".","_")}" value="${r"#{"}${entityDescriptor.name}${r"}"}" <#if entityDescriptor.required>required="true" requiredMessage="${r"#{"}${bundle}.Edit${entityName}RequiredMessage_${entityDescriptor.id?replace(".","_")}${r"}"}"</#if>>
<f:selectItems value="${r"#{"}${entityDescriptor.valuesGetter}${r"}"}"
var="${entityDescriptor.id?replace(".","_")}Item"
itemValue="${r"#{"}${entityDescriptor.id?replace(".","_")}Item${r"}"}"/>
</p:selectOneMenu>
<#elseif entityDescriptor.relationshipMany>
<p:selectManyMenu id="${entityDescriptor.id?replace(".","_")}" value="${r"#{"}${entityDescriptor.name}${r"}"}" <#if entityDescriptor.required>required="true" requiredMessage="${r"#{"}${bundle}.Edit${entityName}RequiredMessage_${entityDescriptor.id?replace(".","_")}${r"}"}"</#if>>
<f:selectItems value="${r"#{"}${entityDescriptor.valuesGetter}${r"}"}"
var="${entityDescriptor.id?replace(".","_")}Item"
itemValue="${r"#{"}${entityDescriptor.id?replace(".","_")}Item${r"}"}"/>
<#else>
<p:inputText id="${entityDescriptor.id?replace(".","_")}" value="${r"#{"}${entityDescriptor.name}${r"}"}" title="${r"#{"}${bundle}.Create${entityName}Title_${entityDescriptor.id?replace(".","_")}${r"}"}" <#if entityDescriptor.required>required="true" requiredMessage="${r"#{"}${bundle}.Create${entityName}RequiredMessage_${entityDescriptor.id?replace(".","_")}${r"}"}"</#if>/>
</#if>
</#list>
</p:panelGrid>
<p:commandButton actionListener="${r"#{"}${managedBean}${r".create}"}" value="${r"#{"}${bundle}.Save${r"}"}" update="display,:${entityName}ListForm:datalist,:growl" oncomplete="handleSubmit(args,'${entityName}CreateDialog');"/>
<p:commandButton value="${r"#{"}${bundle}.Cancel${r"}"}" onclick="${entityName}CreateDialog.hide()"/>
</h:panelGroup>
</h:form>
</p:dialog>
</ui:composition>
</html>