获取栏目内容的知识点总结:SubjectInfoSortPortlet类型笔记(有父子层级关系)

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib prefix="s" uri="/struts-tags"%>

<%@ page import="java.text.SimpleDateFormat"%>

<%@ page import="com.taiji.waf.common.*"%>

<%@ page import="com.taiji.waf.util.*"%>

<%@ page import="com.taiji.waf.cms.business.*"%>

<%@ page import="com.taiji.waf.portlet.cms.*"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>



<%    //从请求中获取创建portal时配置的栏目(InfoSort栏目的类型)

    InfoSort infoSort = (InfoSort) request.getAttribute("infoSort");

    //得到栏目的id

    String infoSortId = infoSort.getInfoSortId();

    //从栏目中获取封装好的栏目信息

    ListDataFormBean bean = infoSort.getBean();

    //从得到的栏目信息中获取信息的List集合

    List flist = bean.getDataList();

    //从请求中获取自己建立的portal的id

    SubjectInfoSortPortlet p = (SubjectInfoSortPortlet) request.getAttribute("portlet");

    //拼接成用于跳转的action值

    String ptView = p.getPortletId() + ".ptview";

%>

<%

    List childrenSortList = null;

    int MAX_INFOLINKTITLE_LENGTH = 18;

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");

    Date now = new Date();

    String today = dateFormat.format(now).substring(5);

    String yesterday = dateFormat.format(DateTimeUtil.getDateBefore(now,1)).substring(5);

    if(infoSort != null) {

        //从获取的父栏目中获取子栏目的List集合(它们的层级可以理解成父子节点的关系)

        childrenSortList = infoSort.getChildrenList();

    }

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>北京市经济和信息化委员会办公业务门户</title>

<link rel="stylesheet" type="text/css" href="css/jxwportal2/style.css">

<script language="javascript" type="text/javascript" src="js/jxwportal2/comm_f.js"></script>

<script>

/**

 * info 详细信息展示页面的跳转js

 * @param a 要进行展示的栏目信息(InfoLinkId)的id值

 * @param b 栏目信息所在栏目(InfoLinkId)的id值

 * @param funcid 有两个值可以填写分别是 showContent和showMore

 * @param showContent 代表跳转到详细信息展示页面

 * @param showMore 表示跳转到更多信息展示页面

 */

function info(a,b){

  infosortForm.funcid.value="showContent";

  infosortForm.infoLinkId.value=a;

  infosortForm.infoSortId.value=b;

  infosortForm.target="_blank";

  infosortForm.submit();

}



/**

 * moreInfo 更多信息展示页面的跳转js

 * @param id 当前栏目(InfoLinkId)的id值

 * @param funcid 有两个值可以填写分别是 showContent和showMore

 * @param showContent 代表跳转到详细信息展示页面

 * @param showMore 表示跳转到更多信息展示页面

 * @param action 填写可以配置更多展示页面portal的id值,如果本portal属于可以

 *     配置更多信息展示页面类型就直接填写自己的id值(完整写法在id后面加上.ptview)

 */

function moreInfo(id){

  infosortForm.funcid.value="showMore";

  infosortForm.infoSortId.value=id;

  infosortForm.target="_blank";

  //infosortForm.action = "<%=p.getPortletId()%>.ptview";

  infosortForm.action = "show.ptview";

  infosortForm.submit();

}

</script>

</head>



<body class="bg_white">

<form name="infosortForm" method="post" action="">

        <input type="hidden" id="funcid" name='funcid' value="" />

        <input type="hidden" id="infoLinkId" name='infoLinkId' value="" />

        <input type="hidden" id="infoSortId" name='infoSortId' value="" />

        <input type="hidden" name="start" value="<%=bean.getStart()%>"/>

        <input type="hidden" name="maxpage" value="<%=bean.getMaxPageCount()%>" />

        <input type="hidden" name="pageLength" value="<%=bean.getLength()%>" />

        

<div class="wrap_new3">

  <div class="gna_title">

            <div class="gna_t_l"></div>

            <div class="gna_t_r">

              <div class="gna_t_rr"></div>

              <div class="gna_t_rl">

                <ul class="gna_chose">

                  <!-- 动态的显示栏目名称 -->

                  <li class="gna_columnbCardOn"  onclick="showCard(this,'gna_columnbCrdInfo','gna_columnbCard')"><%=infoSort.getInfoSortName() %></li>

                  <li class="gna_columnbCardOff" onclick="showCard(this,'gna_columnbCrdInfo','gna_columnbCard')"><%=((InfoSort)childrenSortList.get(0)).getInfoSortName() %></li>

                  <li class="gna_columnbCardOff" onclick="showCard(this,'gna_columnbCrdInfo','gna_columnbCard')"><%=((InfoSort)childrenSortList.get(1)).getInfoSortName() %></li>

                  <li class="gna_columnbCardOff" onclick="showCard(this,'gna_columnbCrdInfo','gna_columnbCard')"><%=((InfoSort)childrenSortList.get(2)).getInfoSortName() %></li>

                </ul>

              </div>

            </div>

            <div class=" clr"></div>

          </div>

  <div class="gna_middle">

            <div class="gna_m_l"></div>

            <div class="gna_m_r">

              <div class="gna_m_rr"></div>

              <div class="gna_m_rl">

              

                <div class="gna_con" id="gna_columnbCrdInfo0" style="display:block;">

                  <ul class="gna_newslist">

                  <%

                      for(int i = 0; i < (flist.size() > 8 ? 8 : flist.size()); i ++){

                          //从栏目信息集合中获取每一条栏目信息(栏目信息的类型InfoLink)

                          InfoLink fInfoLink = (InfoLink)flist.get(i);

                          //下面就可以得到自己想要的具体栏目信息内容了

                          String time = dateFormat.format(fInfoLink.getUpdateTime()).substring(5);

                          String title = fInfoLink.getInfoLinkTitle();

                        if(time.equals(today) || time.equals(yesterday)) {

                      %>

                          <li>

                        <span class="gna_newsdata">[<%= time%>]</span>

                        <a href="javascript:info('<%=fInfoLink.getInfoLinkId()%>','<%=infoSort.getInfoSortId()%>')" title="<%= title%>">

                        <span class="f_l"><%= DisplayUtil.SubStrDot(title,MAX_INFOLINKTITLE_LENGTH)%></span><div class="new"></div></a>

                          </li>

                      <% 

                          }else {

                      %>

                          <li>

                        <span class="gna_newsdata">[<%= time%>]</span>

                        <a href="javascript:info('<%=fInfoLink.getInfoLinkId()%>','<%=infoSort.getInfoSortId()%>')" title="<%= title%>">

                        <%= DisplayUtil.SubStrDot(title,MAX_INFOLINKTITLE_LENGTH)%></a>

                          </li>

                      <%    

                          }

                      }

                  %>

                  <%

                     //栏目显示补白

                  if(flist.size() < 8) {

                      for(int i = 0; i < (8 - flist.size()); i++) {

                         %>

                         <li></li>

                         <%

                      }

                  }

                  %>

                  </ul>

                  <!-- 更多页面的跳转 -->

                  <span class="gna_more"><a href="javascript:moreInfo('<%=infoSort.getInfoSortId()%>')">更多>></a></span>

                  <div class="clr"></div>

                </div>

                

                <%

                  if(childrenSortList != null && childrenSortList.size() > 0) {

                    for(int i =0; i < childrenSortList.size(); i++) {

                      //从存放子栏目的集合中得到每一个子栏目(栏目的类型InfoSort)

                      InfoSort childrenSort = (InfoSort)childrenSortList.get(i);

                      //从栏目中获取封装好的栏目信息

                      ListDataFormBean beans = childrenSort.getBean();

                    //从得到的栏目信息中获取栏目信息的List集合

                      List cList = beans.getDataList();

                %>

                <div class="gna_con" id="gna_columnbCrdInfo<%= i+1%>" style="display:none;">

                  <ul class="gna_newslist">

                  <% 

                      for(int j = 0; j < (cList.size() > 8 ? 8 : cList.size()); j++) {

                          //从栏目信息集合中获取每一条栏目信息(栏目信息的类型InfoLink)

                          InfoLink cInfoLink = (InfoLink)cList.get(j);

                          //下面就可以得到自己想要的具体栏目信息内容了

                          String time = dateFormat.format(cInfoLink.getUpdateTime()).substring(5);

                          String title = cInfoLink.getInfoLinkTitle();

                          if(time.equals(today) || time.equals(yesterday)) {

                      %>

                          <li>

                        <span class="gna_newsdata">[<%= time%>]</span>

                        <a href="javascript:info('<%=cInfoLink.getInfoLinkId()%>','<%=infoSort.getInfoSortId()%>')" title="<%= title%>">

                        <span class="f_l"><%= DisplayUtil.SubStrDot(title,MAX_INFOLINKTITLE_LENGTH)%></span><div class="new"></div></a>

                          </li>

                      <%            

                          }else {

                         %>

                        <li>

                        <span class="gna_newsdata">[<%= time%>]</span>

                        <a href="javascript:info('<%=cInfoLink.getInfoLinkId()%>','<%=infoSort.getInfoSortId()%>')" title="<%= title%>">

                        <%= DisplayUtil.SubStrDot(title,MAX_INFOLINKTITLE_LENGTH)%></a>

                          </li>

                      <%            

                          }

                      }

                  %>

                  <%

                  //栏目显示补白

                  if(cList.size() < 8) {

                      for(int k = 0; k < (8 - cList.size()); k++) {

                         %>

                         <li></li>

                         <%

                      }

                  }

                  %>

                  </ul>

                  <!-- 更多页面的跳转 -->

                  <span class="gna_more"><a href="javascript:moreInfo('<%=childrenSort.getInfoSortId()%>')">更多>></a></span>

                  <div class="clr"></div>

                </div>

                <%

                  }

                  }

                %>

              </div>

            </div>

          </div>

</div>

</form>

</body>

</html>

 

获取父子栏目内容的知识点总结:

com.taiji.waf.portlet.cms.SubjectInfoSortPortlet

1.得到父infoSor内容信息的步骤:

//从请求中获取配制好的栏目信息
InfoSort infoSort = (InfoSort)request.getAttribute("infoSort");

//得到存放栏目信息内容的容器

ListDataFormBean bean = infoSort.getBean();

//从容器中取得List

List gnList = bean.getDataList();

//获取相应编号的一条信息

InfoLink infoLink = (InfoLink)gnList.get(i);

//得到信息的具体内容

String time = infoLink.getUpdateTime();

String title = infoLink.getInfoLinkTitle();

2.从父infoSort得到子infoSort栏目内容信息的步骤:

List subjectSortList = infoSort.getChildrenList();

InfoSort subjectSort = (InfoSort)subjectSortList.get(0);

ListDataFormBean beans = subjectSort.getBean();

List subjectList = beans.getDataList();

InfoLink subject = (InfoLink)subjectList.get(i);

String time = subject.getUpdateTime();

String title = subject.getInfoLinkTitle();(步骤相同不再注释)

你可能感兴趣的:(portlet)