[SEAM] 修改了SEAM GEN的模板,支持many to one父对象的下拉框。

chicochen 2010-04-22
editproperty.xhtml.ftl中增加:
<#if isToOne(property)>
				<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
				<#assign parentName = parentPojo.shortName?uncap_first>
				
				<s:decorate id="${label(property.name)}Field" template="layout/edit.xhtml">
						<ui:define name="label">${label(property.name)}</ui:define>
						<h:selectOneMenu id="${property.name}"   required="true"
										 value="${'#'}{${parentName}Home.${parentName}Id}"> 
									
									<f:selectItem itemLabel="Please Select" itemValue="" />
									
									<s:selectItems value="${'#'}{${parentName}List.resultList}" 
											var="p_${parentName}" itemValue="${'#'}{p_${parentName}.id}" label="${'#'}{p_${parentName}.name}" /> 
									
									<a:support event="onblur" reRender="${parentName}Field" 
											bypassUpdates="true" ajaxSingle="true"/>
									<a:support event="onchange" reRender="actionButtonsArea" 
											bypassUpdates="false" ajaxSingle="true" />
						</h:selectOneMenu>
				</s:decorate>
</#if>

生成后的代码:
				<s:decorate id="DepartmentField" template="layout/edit.xhtml">
						<ui:define name="label">Department</ui:define>
						<h:selectOneMenu id="department"   required="true"
										 value="#{departmentHome.departmentId}"> 
									
									<f:selectItem itemLabel="Please Select" itemValue="" />
									
									<s:selectItems value="#{departmentList.resultList}" 
											var="p_department" itemValue="#{p_department.id}" label="#{p_department.name}" /> 
									
									<a:support event="onblur" reRender="departmentField" 
											bypassUpdates="true" ajaxSingle="true"/>
									<a:support event="onchange" reRender="actionButtonsArea" 
											bypassUpdates="false" ajaxSingle="true" />
						</h:selectOneMenu>
				</s:decorate>
subaochen 2010-04-27
很好,符合国人习惯
yzhw 2011-05-18
这个很强大啊,项目中用到的都是自己手写
Global site tag (gtag.js) - Google Analytics