你被耍了(appfuse)

  最近正用appfuse1.9.4(jsf+spring+hibernate)实现一个网站(http://www.p2prent.cn),经常被appfuse的一些设计搞得晕头转向,学习appfuse的时间成本也确实很大,但一旦真正理解之后却常常要为作者喝彩.

 appfuse不管web层用什么框架都引入了struts-menu作为框架的菜单实现.简单的菜单应用当然依样画葫芦就可以了,但是我想通过菜单实现页面某些功能的初始化,简单的说就是在点菜单的时候会执行类中的函数.在struts-menu的官方网站转了一圈又到其他地方浏览了一下始终没有找到解决办法.

 本来已经打算在构造函数里写了:)

 忽然看到管理页面中的"编辑信息",噫,他是怎么实现初始化的呢.

 在menu-config.xml中可以清楚的看到当点击"编辑信息"的时候页面会跳转到 editProfile.html页面,再看editProfile.xhtml

xml 代码
  1. <html xmlns="http://www.w3.org/1999/xhtml"  
  2.       xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">  
  3.   
  4. <head>  
  5.     <meta name="menu" content="UserMenu"/>  
  6. head>  
  7.   
  8. <f:view>  
  9.   
  10. <h:form id="userProfile">  
  11.     <h:commandLink action="#{userForm.edit}" id="edit"/>  
  12. h:form>  
  13.   
  14. <script type="text/javascript">  
  15.     var f = document.forms['userProfile'];   
  16.     f.elements['userProfile:_link_hidden_'].value='userProfile:edit';   
  17.     f.submit();   
  18. script>  
  19.   
  20. f:view>  
  21. html>  

   居然是这样的!!!

   朋友们不用再解释了吧,不知道你有没有被耍的经历呢.

你可能感兴趣的:(spring,框架,struts,JSF,Appfuse)