熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

Struts Layout

2022-06-13   來源: Java開源技術 

  
  正如軟件有他的皮膚一樣我們的系統也有自己的皮膚如果我們的應用系統可以讓不同的客戶選擇自己喜歡的風格那麼我們將會感到無比的開心難道不是嗎?
  可以更加容易的使用標記庫更輕松的開發出系統風格一致的系統
  Struts基於mvc的frameWork廣泛的應用的jee開發領域中
  · configure struts for the webapp
  · configure the strutslayout treeview and sort action (just copy the corresponding lines of the strutsconfig file of the example application)
  · copy the strutslayoutjar file into the WEBINF/lib directory
  · declare the strutslayout tld file in the webxml file
  · copy the menujar file from the strutslayout example application into the WEBINF/lib directory
  · put a version of the common BeanUtils library in the WEBINF/lib directory if using struts
  · copy the strutslayouttld file into the WEBINF directory
  · copy the files in the config and images directory of the strutslayout example application in your new webapp
  · if forward to Tiles definition will be used with sorting or paging on the server the strutslayout request processor
  
  example:
  
  <layout:form action= styleClass=FORM>
  <layout:grid cols=>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  </layout:grid>
  <layout:grid cols=>
  <layout:text key=Text input field property=username/>
  <layout:text key=Text input field property=username/>
  <layout:text key=Text input field property=username/>
  <layout:text key=Text input field property=username/>
  </layout:grid>
  </layout:form>
  
  
  
  <layout:form action= styleClass=FORM>
  <layout:row>
  <layout:collection name=users styleClass=FORM>
  <layout:collectionItem title=userslogin property=login/>
  <layout:collectionItem title=usersfirstname property=firstname/>
  <layout:collectionItem title=userslastname property=lastname/>
  <layout:collectionItem title=userssociety property=society/>
  </layout:collection>
  <layout:column>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  </layout:column>
  </layout:row>
  </layout:form>
  
  
  <layout:form action= styleClass=FORM>
  <layout:grid cols=>
  <layout:collection name=users styleClass=FORM length=>
  <layout:collectionItem title=userslogin property=login/>
  <layout:collectionItem title=usersfirstname property=firstname/>
  <layout:collectionItem title=userslastname property=lastname/>
  <layout:collectionItem title=userssociety property=society/>
  </layout:collection>
  <layout:column>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  </layout:column>
  </layout:grid>
  <layout:space/>
  <layout:grid cols=>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  <layout:text key=Field property=username/>
  <layout:space/>
  <layout:text key=Field property=username/>
  <layout:space/>
  </layout:grid>
  </layout:form>
  
  
  
  jsp page:
  [
  
  <%@ page language=java %>
  <%@ taglib uri=/WEBINF/strutsbeantld prefix=bean %>
  <%@ taglib uri=/WEBINF/strutshtmltld prefix=html %>
  
  <html:html locale=true>
  <head>
  <title><bean:message key=logontitle/></title>
  <html:base/>
  </head>
  <body bgcolor=white>
  
  <html:errors/>
  
  <html:form action=/logon focus=username>
  <table border= width=%>
  
  <tr>
  <th align=right>
  <bean:message key=promptusername/>
  </th>
  <td align=left>
  <html:text property=username size= maxlength=/>
  </td>
  </tr>
  
  <tr>
  <th align=right>
  <bean:message key=promptpassword/>
  </th>
  <td align=left>
  <html:password property=password size= maxlength=
  redisplay=false/>
  </td>
  </tr>
  
  <tr>
  <td align=right>
  <html:submit property=submit value=Submit/>
  </td>
  <td align=left>
  <html:reset/>
  </td>
  </tr>
  
  </table>
  
  </html:form>
  
  </body>
  </html:html>
  
  ]
  
  layout page:
  [
  <%@ page language=java %>
  <%@ taglib uri=/WEBINF/strutslayouttld prefix=layout %>
  <%@ taglib uri=/WEBINF/strutshtmltld prefix=html %>
  <layout:html locale=true styleClass=FORM>
  <html:errors property=orgapachestrutsactionGLOBAL_ERROR/>
  <layout:form action=/logondo focus=username key=logontitle styleClass=FORM>
  <layout:field key=promptusername property=username size= maxlength= isRequired=true styleClass=LABEL/>
  <layout:field key=promptpassword property=password size= maxlength= type=password styleClass=LABEL isRequired=true/>
  <layout:formActions>
  <layout:submit property=submit value=Submit/>
  <layout:reset/>
  </layout:formActions>
  </layout:form>
  </layout:html>
  
  
  使用layout可以更加容易的開發!

From:http://tw.wingwit.com/Article/program/Java/ky/201311/28200.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.