zoukankan      html  css  js  c++  java
  • liferay UI 标签

    参考:https://blog.csdn.net/lan861698789/article/details/7563280

    摘自:http://blog.csdn.net/zhichao_boole/article/details/6801539

     

    如果你已下载liferay source,标签库位于/util-taglib/src/META-INF/liferay-ui.tld。Java classes位于/util-taglib/src/com/liferay/taglib/ui。JSPfragments位于portal-web/docroot/html/taglib/ui。

    可以参考liferay wiki page “How to search for a taglib's code”以获取更多的信息。

    要使用UI,就需要在你的JSP中加入这条语句:

    <%@ tagliburi="http://liferay.com/tld/ui"prefix="liferay-ui" %> 


    1 error

    <liferay-ui: errorkey=””message=””/> 


    用于显示操作失败的信息。使用"portlet-msg-error" CSS class。默认情况下,在红框里显示错误信息。

    显示错误,(至少)需要以下两步:

    1.      在后台处理程序中通过SessionErrors.add(req,key)设置key的值:

    com.liferay.portal.kernel.servlet.SessionErrors.add(PortletRequestportletRequest, String key) 



    2.      message指定显示信息对应的资源文件中key的值。key值必须唯一。

    <liferay-ui:errormessage="message"key="key"/> 



    示例:

    1.  
      <% SessionErrors.add(renderRequest,"key"); %>
    2.  
      <liferay-ui:errormessageliferay-ui:errormessage="this-is-an-error"key="key"/>



    2 message

    Key为在资源文件中配置的值

    示例:

    <liferay-ui:message key="Feed-add-Feed-Description"/>
    


    3 tags-summary

    4 journal-article

    使用用户定义的模板显示journal article。

    四个参数:

    1. articleId = uniqueID of content article

    2 .groupId = group of user

    3. showTitle = show title of article trueor false

    4 .templateId = which of the definedtemplates for this journal article to use. Note that there is a bug (reportedhere) in liferay versions before 6.0.2 where templateId is ignored.

    示例:

    <liferay-ui:journal-articlearticleId="<%=menuIdString%>" groupId="<%=groupId%>"/>  


    5 bread-crumb

    6 tabs

    Liferay中自带的Tab标签UI,可以根据其name属性显示相应的标签名,多个标签名字用逗号分割, 但逗号前后都不能有多余空格。param参数是是tabs1还是tabsn,命名规范是tabsx,是几级菜单的标识。url是每个对应的name名字的要跳转的页面,最大支持10个标签名。

    1.  
      <liferay-ui:tabsnames=”add,update”param=”cur”url=”<%= %>”refresh=”<%= true%”>
    2.  
      <c:iftest=”<%= %>”>
    3.  
      <liferay-util:includepageliferay-util:includepage=””>
    4.  
      <liferay-util:paramname=””value=””>
    5.  
      </liferay-util:include>
    6.  
      </c:if>
    7.  
      </liefray-ui:tabs>



    注:实际使用当中通过这种方式:

    首先,从页面获取参数,也就是<liferay-ui:tabs 标签当中设置的param属性:

    String cur=ParamUtil.getString(request,"cur","add"); 



    第二个参数是设置的参数名,最后一个参数为你想要默认显示的页面。

    其次定义url:

    1.  
      PortletURL portletURL =renderResponse.createRenderURL();
    2.  
      portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
    3.  
      portletURL.setParameter("struts_action","/ext/user/view");
    4.  
       


    然后定义liferay-ui:tabs标签:

    1.  
      <liferay-ui:tabsnamesliferay-ui:tabsnames="uploadModelFile,uploadDataFile"param="cur"value="<%= cur%>"url="<%= portletURL.toString()%>"refresh="<%= true%>">
    2.  
      <c:if test='<%= cur.equals("add") %>'>
    3.  
      <liferay-util:includepage="/html/portlet/ext/user/add.jsp">
    4.  
      </liferay-util:include>
    5.  
      </c:if>
    6.  
      <c:if test='<%= cur.equals("update") %>'>
    7.  
      <liferay-util:includepage="/html/portlet/ext/user/update.jsp">
    8.  
      </liferay-util:include>
    9.  
      </c:if>
    10.  
      </liferay-ui:tabs>


    标签会传递相应的参数,然后选择显示要显示的页面。

    另外,liferay的多tab页还可以通过下面这种方式实现:

    首先定义url:

    1.  
      PortletURL portletURL =renderResponse.createRenderURL();
    2.  
      portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
    3.  
      portletURL.setParameter("struts_action","/ext/user/view");


     

    然后定义liferay-ui:tabs标签:

    1.  
      <liferay-ui:tabsnamesliferay-ui:tabsnames="add,update"url="<%= portletURL.toString()%>"refresh="<%= true%>">
    2.  
      <liferay-ui:section>
    3.  
      <liferay-util:includepage="/html/portlet/ext/user/add.jsp">
    4.  
      </liferay-util:include>
    5.  
      </liferay-ui:section>
    6.  
      <liferay-ui:section>
    7.  
      <liferay-util:includepage="/html/user/update.jsp">
    8.  
      </liferay-util:include>
    9.  
      </liferay-ui:section>
    10.  
      </liferay-ui:tabs>


     

    这样,就可以根据在names里面定义的顺序,显示所要显示的页面。

    7 section

    1.  
      <liferay-ui:section>
    2.  
      <c:iftest=”<%= %>”>
    3.  
      <liferay-util:includepage=””>
    4.  
      <liferay-util:paramname=””value=””>
    5.  
      </liferay-util:include>
    6.  
      </c:if>
    7.  
      </liferay-ui:section>


    8 page-iterator

     
    <liferay-ui:page-iteratorcurParam=””curValue=””delta=”” maxPages=””total=”” url=””/> 


    参数:(cur、curParam、total为必须参数)

    1.      curParam指定保存当前页码的参数名称;

    2.      curValue保存当前页码;

    3.      delta指定每页显示的记录数量;

    4.      maxPages指定Portlet正常模式下的显示的最大记录数;

    5.      total指定数据的总记录数;

    6.      url 指定翻页时的请求URL.

    9 search-container

    results- This is where you input the results. resultsshould be of type List. The important part is to make sure that your methodsupports some way to search from a beginning index to an end index in order toprovide a good performance pagination. Note how we usesearchContainer.getStart() for the first index and searchContainer.getEnd() forthe second index. As mentioned above, the searchContainer object is availablebecause it has been instantiated already. Some other methods you can use:

    searchContainer.getStart() - gets starting index of current resultspage.

    searchContainer.getResultsEnd() - gets ending index of currentresults page or index of last result (i.e. will return 3 if delta is 5 butthere are only 3 results).

    searchContainer.getEnd() - gets last index of current results pageregardless of size of actually results (i.e. will return 5 if delta is 5 evenif there is only 3 results. Will throw out of bounds errors).

    searchContainer.getCur() - gets number of current results page.

    searchContainer.setTotal() - must be set so getResultsEnd() knowswhen to stop.

    total- This is where you input the total number of itemsin your list

    className - The type of Object in your List. In this case, we have a List ofUser objects.

    keyProperty - Primary Key

    modelVar - The name of the variable to represent your model. In this casethe model is the User object.

    <liferay-ui:search-container-column-text> - Text column

    name - Name of the column

    value - Value of the column

    href - the text in this coulmn will be a link the this URL

    orderable - allows the user to order the list of items by this column

    property - This will automatically look in the User object for the"firstName" property. It's basically the same thing asuser.getFirstName()

    <liferay-ui:search-iterator/> - This is what actually iterates through anddisplays the List

    示例:

    1.  
      <liferay-ui:search-container
    2.  
      delta="10"
    3.  
      emptyResultsMessage="no-users-were-found"><liferay-ui:search-container-results
    4.  
      results="<%=UserLocalServiceUtil.search(company.getCompanyId(),
    5.  
      searchTerms.getKeywords(),searchTerms.getActiveObj(),userParams,
    6.  
      searchContainer.getStart(),searchContainer.getEnd(),
    7.  
      searchContainer.getOrderByComparator()); %>"
    8.  
      total="<%=UserLocalServiceUtil.searchCount(company.getCompanyId(),
    9.  
       
    10.  
       

    1.  
      searchTerms.getKeywords(),searchTerms.getActiveObj(),userParams);%>"/>
    2.  
      <liferay-ui:search-container-row
    3.  
      className="com.liferay.portal.model.User"
    4.  
      keyProperty="userId"
    5.  
      modelVar="user">
    6.  
      <liferay-ui:search-container-column-text
    7.  
      name="name"value="<%= user.getFullName()%>"/>
    8.  
      <liferay-ui:search-container-column-text
    9.  
      name="first-name"property="firstName"/>
    10.  
      </liferay-ui:search-container-row>
    11.  
      <liferay-ui:search-iterator/>
    12.  
      t;/liferay-ui:search-container>

    官网UI:http://docs.liferay.com/portal/6.1/taglibs/liferay-ui/tld-summary.html
    由一个网址: http://liferaydemystified.blogspot.com/2011/05/liferay-ui-taglib.html
  • 相关阅读:
    ffmpeg参数说明
    【FFmpeg】FFmpeg常用基本命令
    ffmpeg最全的命令参数
    数据库总结
    linux redis安装及JAVA使用jedis
    记录一次工作中jvm被linux杀死的调查
    ExecutorService线程池submit的使用
    java四种引用与回调函数
    java排序
    NIO教程笔记
  • 原文地址:https://www.cnblogs.com/show58/p/13795287.html
Copyright © 2011-2022 走看看