的确方便了很多!
xml 代码
- <tr>
- <td>
- <s:decorate template="/page/tiles/formFieldDecorate.xhtml">
- <ui:define name="label">分类1</ui:define>
- <h:selectOneMenu value="#{_catalog1}" converter="#{entityConverter}">
- <s:selectItems value="#{appCache.catalog1List}"
- var="cata1" label="#{cata1.name}" noSelectionLabel="请选择"/>
- <a4j:support event="onchange"
- actionListener="#{courseMaintAction.loadCata2ByCata1}"
- reRender="cata2Area" requestDelay="0" ajaxSingle="true" />
- </h:selectOneMenu>
- </s:decorate>
- </td>
- </tr>
- <tr>
- <td>
- <s:decorate template="/page/tiles/formFieldDecorate.xhtml">
- <ui:define name="label">分类2</ui:define>
- <a4j:outputPanel id="cata2Area">
- <h:selectOneMenu value="#{_catalog2}" converter="#{entityConverter}">
- <s:selectItems value="#{_catalog2List}" var="cata2" label="#{cata2.name}" noSelectionLabel="请选择" />
- </h:selectOneMenu>
- </a4j:outputPanel>
- </s:decorate>
- </td>
- </tr>
java 代码
- //$Id: NavigateeAction.java,v 1.1 2007/02/21 11:09:46 chicochen Exp $
- package com.eastidea.yctraining.action;
- import static org.jboss.seam.ScopeType.SESSION;
- import java.util.List;
- import java.util.Set;
- import javax.ejb.Remove;
- import javax.ejb.Stateful;
- import org.jboss.seam.annotations.Begin;
- import org.jboss.seam.annotations.Destroy;
- import org.jboss.seam.annotations.End;
- import org.jboss.seam.annotations.In;
- import org.jboss.seam.annotations.Name;
- import org.jboss.seam.annotations.Out;
- import org.jboss.seam.annotations.web.RequestParameter;
- import com.eastidea.yctraining.action.base.BaseMaintActionImpl;
- import com.eastidea.yctraining.entity.Catalog1;
- import com.eastidea.yctraining.entity.Catalog2;
- import com.eastidea.yctraining.entity.Course;
- import com.eastidea.yctraining.entity.Organization;
- import com.eastidea.yctraining.service.CourseMaintService;
- @Stateful
- @Name("courseMaintAction")
- public class CourseMaintActionImpl extends BaseMaintActionImpl implements CourseMaintAction {
- private static final long serialVersionUID = -7494995399977805979L;
- @In(value="courseMaintService", create=true)
- private CourseMaintService courseMaintService;
- @In(required = false, scope = SESSION)
- protected Organization currentOrg;
- //
- @RequestParameter
- private Long _courseid;
- @In(required = false)@Out(required = false)
- private Catalog1 _catalog1;
- @In(required = false)@Out(required = false)
- private Catalog2 _catalog2;
- @In(required = false)@Out(required = false)
- private Course _course;
- @In(required = false)@Out(required = false)
- private Set<Catalog2> _catalog2List;
- @Destroy @Remove
- public void destroy() {
- }
- @Begin(join=true)
- public void loadCata2ByCata1(){
- _catalog2List = _catalog1.getCata2Collection();
- }
- @Begin(join=true)
- public void create() {
- myAct = "create";
- _course = new Course();
- }
- @End
- public void save() {
- if (myAct.equals("true")) {
- _course.setCatalog1(_catalog1);
- _course.setCatalog2(_catalog2);
- _course.setOrganization(currentOrg);
- courseMaintService.saveCourse(_course);
- }
- }
- public void edit() {
- int i =0;
- i++;
- }
- public void update() {
- // TODO Auto-generated method stub
- }
- public void view() {
- // TODO Auto-generated method stub
- }
- public void delete() {
- // TODO Auto-generated method stub
- }
- public void cancel() {
- // TODO Auto-generated method stub
- }
- }