SEAM+AJAX4JSF 实现动态菜单

的确方便了很多!
xml 代码
  1. <tr>  
  2.  <td>  
  3.         <s:decorate template="/page/tiles/formFieldDecorate.xhtml">  
  4.             <ui:define name="label">分类1</ui:define>  
  5.             <h:selectOneMenu value="#{_catalog1}" converter="#{entityConverter}">  
  6.     <s:selectItems value="#{appCache.catalog1List}"    
  7.      var="cata1" label="#{cata1.name}" noSelectionLabel="请选择"/>            
  8.     <a4j:support event="onchange"  
  9.      actionListener="#{courseMaintAction.loadCata2ByCata1}"  
  10.      reRender="cata2Area" requestDelay="0"  ajaxSingle="true" />  
  11.    </h:selectOneMenu>  
  12.         </s:decorate>  
  13.        </td>  
  14. </tr>  
  15. <tr>  
  16.  <td>  
  17.          <s:decorate template="/page/tiles/formFieldDecorate.xhtml">  
  18.              <ui:define name="label">分类2</ui:define>  
  19.               <a4j:outputPanel id="cata2Area">  
  20.                <h:selectOneMenu value="#{_catalog2}" converter="#{entityConverter}">  
  21.        <s:selectItems value="#{_catalog2List}" var="cata2" label="#{cata2.name}" noSelectionLabel="请选择" />  
  22.       </h:selectOneMenu>  
  23.      </a4j:outputPanel>  
  24.          </s:decorate>  
  25.  </td>  
  26. </tr>  
java 代码
  1. //$Id: NavigateeAction.java,v 1.1 2007/02/21 11:09:46 chicochen Exp $   
  2. package com.eastidea.yctraining.action;   
  3.   
  4. import static org.jboss.seam.ScopeType.SESSION;   
  5.   
  6. import java.util.List;   
  7. import java.util.Set;   
  8.   
  9. import javax.ejb.Remove;   
  10. import javax.ejb.Stateful;   
  11.   
  12. import org.jboss.seam.annotations.Begin;   
  13. import org.jboss.seam.annotations.Destroy;   
  14. import org.jboss.seam.annotations.End;   
  15. import org.jboss.seam.annotations.In;   
  16. import org.jboss.seam.annotations.Name;   
  17. import org.jboss.seam.annotations.Out;   
  18. import org.jboss.seam.annotations.web.RequestParameter;   
  19.   
  20. import com.eastidea.yctraining.action.base.BaseMaintActionImpl;   
  21. import com.eastidea.yctraining.entity.Catalog1;   
  22. import com.eastidea.yctraining.entity.Catalog2;   
  23. import com.eastidea.yctraining.entity.Course;   
  24. import com.eastidea.yctraining.entity.Organization;   
  25. import com.eastidea.yctraining.service.CourseMaintService;   
  26.   
  27. @Stateful  
  28. @Name("courseMaintAction")   
  29. public class CourseMaintActionImpl extends BaseMaintActionImpl implements CourseMaintAction {   
  30.   
  31.     private static final long serialVersionUID = -7494995399977805979L;   
  32.   
  33.     @In(value="courseMaintService", create=true)    
  34.     private CourseMaintService courseMaintService;   
  35.        
  36.     @In(required = false, scope = SESSION)   
  37.     protected Organization currentOrg;   
  38.        
  39.     //   
  40.     @RequestParameter  
  41.     private Long _courseid;   
  42.        
  43.     @In(required = false)@Out(required = false)   
  44.     private Catalog1 _catalog1;   
  45.     @In(required = false)@Out(required = false)   
  46.     private Catalog2 _catalog2;   
  47.        
  48.     @In(required = false)@Out(required = false)   
  49.     private Course _course;    
  50.        
  51.     @In(required = false)@Out(required = false)   
  52.     private Set<Catalog2> _catalog2List;           
  53.        
  54.     @Destroy @Remove  
  55.     public void destroy() {   
  56.     }   
  57.   
  58.     @Begin(join=true)   
  59.     public void loadCata2ByCata1(){   
  60.         _catalog2List = _catalog1.getCata2Collection();   
  61.     }   
  62.        
  63.     @Begin(join=true)   
  64.     public void create() {   
  65.         myAct = "create";   
  66.         _course = new Course();        
  67.     }   
  68.   
  69.     @End  
  70.     public void save() {   
  71.         if (myAct.equals("true")) {   
  72.             _course.setCatalog1(_catalog1);   
  73.             _course.setCatalog2(_catalog2);   
  74.             _course.setOrganization(currentOrg);   
  75.             courseMaintService.saveCourse(_course);   
  76.         }   
  77.     }   
  78.   
  79.     public void edit() {   
  80.         int i =0;   
  81.         i++;   
  82.            
  83.     }   
  84.   
  85.     public void update() {   
  86.         // TODO Auto-generated method stub   
  87.            
  88.     }   
  89.   
  90.     public void view() {   
  91.         // TODO Auto-generated method stub   
  92.            
  93.     }   
  94.   
  95.     public void delete() {   
  96.         // TODO Auto-generated method stub   
  97.            
  98.     }   
  99.        
  100.     public void cancel() {   
  101.         // TODO Auto-generated method stub   
  102.            
  103.     }   
  104.   
  105. }   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值