kapok

垃圾桶,嘿嘿,我藏的这么深你们还能找到啊,真牛!

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  455 随笔 :: 0 文章 :: 76 评论 :: 0 Trackbacks
http://rabbit8.blogchina.com/blog/article_144619.1057775.html
在AppFuse中集成ValueList的方法
2005年 03月08日
怎样在AppFuse中集成ValueList

1.在web.xml中添加,/WEB-INF/classes/standardJspApplicationContext.xml。
<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext-*.xml,/WEB-INF/classes/standardJspApplicationContext.xml</param-value>
</context-param>
   
2.把valuelist.tld拷贝到WEB-INF下。
3.在taglibs.jsp中添加valuelist.tld。
4.将standardJspApplicationContext.xml、i18n.properties、microsoftLook.properties、simpleLook.properties、classicLook.properties文件复制到/WEB-INF/classes下。
5.在applicationContext-resources.xml的<beans></beans>中添加:
  <bean id="resourceI18nBundle" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename"><value>i18n</value></property>
  </bean>
  和
   
  <bean id="valueListHandler" singleton="true"
        class="net.mlw.vlh.DefaultValueListHandlerImpl">   
    <property name="config.adapters">
      <map>
     
        <entry key="userlist">
          <bean class="net.mlw.vlh.adapter.hibernate.Hibernate20Adapter">
            <property name="sessionFactory"><ref bean="sessionFactory"/></property>
            <property name="defaultNumberPerPage"><value>2</value></property>
            <property name="defaultSortColumn"><value>lastName</value></property>
            <property name="defaultSortDirection"><value>asc</value></property>
            <property name="hsql">
              <value>
                FROM org.appfuse.model.User AS vo
                /~name: WHERE vo.lastName LIKE {name} ~/
                /~sortColumn: ORDER BY vo.[sortColumn] [sortDirection]~/
              </value>
            </property>
          </bean>
        </entry>
       
        <!--entry key="players2">
          <bean class="net.mlw.vlh.adapter.hibernate.Hibernate20Adapter">
            <property name="sessionFactory"><ref bean="mySessionFactory"/></property>
            <property name="defaultNumberPerPage"><value>20</value></property>
            <property name="defaultSortColumn"><value>lastName</value></property>
            <property name="defaultSortDirection"><value>asc</value></property>
            <property name="namedQuery"><value>playerList</value></property>
          </bean>
        </entry-->
       
       
      </map>
    </property>
   
  </bean>
 
  上面配置中的"sessionFactory"为原来配置好的。
  "defaultNumberPerPage"为每页显示的记录行数。
  "defaultSortColumn"排序列。
  "org.appfuse.model.User"为POJO的名字。
 
6.将相关的样式表的内容合并到原有的样式表中。
7.将valuelist.jar添加到类路径下。

 


8:如果为行添加onclick事件,注意要对"&"进行转义-document.location='editUser.html?username=<c:out value="${User.username}"/>\&from=list';:
<vlh:root value="valueList" configName="classicLook" url="?" includeParameters="*" >


<table width="600" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" nowrap="true">
          <c:out value="${list.valueListInfo.totalNumberOfEntries}"/> Total
          - Page (<c:out value="${list.valueListInfo.pagingPage}"/> of <c:out value="${list.valueListInfo.totalNumberOfPages}"/>)
          &nbsp;
        </td>
        <td align="right">
          <vlh:paging pages="5"><c:out value="${page}"/>&nbsp;</vlh:paging>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          Export to: &nbsp;&nbsp;
    <vlh:filter url="example-export-format.jsp?format=excel&">
      <img src="images/export_excel.png" border="0"> Excel
    </vlh:filter>
    <vlh:filter url="example-export-format.jsp?format=csv&">
      <img src="images/export_csv.png" border="0"> CSV
    </vlh:filter>
   
    <table width="450" class="classicLook" cellspacing="0" cellpadding="0">
      <vlh:row bean="User">
 <vlh:attribute name="onclick">
   document.location='editUser.html?username=<c:out value="${User.username}"/>\&from=list';
        </vlh:attribute>

        <vlh:column title="username"   property="username"   sortable="desc" />
        <vlh:column title="firstName"   property="firstName"   sortable="desc" />
        <vlh:column title="lastname"   property="lastName"   sortable="desc" />
        <vlh:column title="email"     property="email"     sortable="desc" />
      </vlh:row>
    </table>
 </td>
      </tr>
    </table>
   
  </vlh:root>


======================================================================
为ValueList添加高亮
1.添加vlh:attribute:<vlh:attribute name="onmouseout">javascript:mouseout(this);</vlh:attribute>。
添加完attribute后的内容如下:

  <vlh:root value="list" url="?" includeParameters="*" >
    <vlh:retrieve name="nbaPlayers" />
   
    <table width="650" class="classicLook" cellspacing="0" cellpadding="0">
      <vlh:row bean="player">
        <vlh:attribute name="onmouseover">javascript:toggle(this);</vlh:attribute>
 <vlh:attribute name="onmouseout">javascript:mouseout(this);</vlh:attribute>
        <vlh:attribute name="id"><%=("player-"+playerRowNumber)%></vlh:attribute>
        <vlh:attribute name="align" value="center" />
       
        <vlh:column title="playerid"   property="playerid"   sortable="desc"/>
        <vlh:column title="teamname"   property="teamname"   sortable="desc" />
        <vlh:column title="firstname"  property="firstname"  sortable="desc">
          <vlh:attribute name="width" value="150"/>
        </vlh:column>
        <vlh:column title="lastname"   property="lastname"   sortable="desc" attributes="width='150'"/>
        <vlh:column title="status"     property="status"     sortable="desc" />
        <vlh:column title="pos"        property="pos"        sortable="desc" />
      </vlh:row>
    </table>
  </vlh:root>


2.添加js函数,添加完函数后的内容如下:
<script>
  var lastId;
  var lastStyle;
  var previousClass = null;
  function toggle(object)
  {
  if( lastId != undefined )
  {
  document.getElementById(lastId).className = lastStyle;
  }
  lastId = object.id;
  lastStyle = object.className;
  previousClass=this.className;
  object.className = "selected";
  }

  function mouseout(object){
   object.className = previousClass;
  }
</script>

 

 

posted on 2005-03-09 00:29 笨笨 阅读(748) 评论(0)  编辑  收藏 所属分类: ALLAppFuse

只有注册用户登录后才能发表评论。


网站导航: