Две ссылки DynamicView - PullRequest
       6

Две ссылки DynamicView

0 голосов
/ 09 ноября 2018

Я использую dynamicViewPanel, который отображает информацию о вложениях пользователя из вида домино. Есть 4 столбца, информация которых отображается правильно. Когда пользователь щелкает первый столбец, открывается другая страница с технической информацией об этом вложении. Что мне нужно сделать, это когда пользователь щелкает 4-й столбец, в котором отображается [править], открывается другая страница, на которой пользователь может редактировать информацию о вложении, которая отображается. Я использую код UserViewCustomizer.

Какие-либо предложения о том, как получить ссылку [edit], чтобы открыть другую страницу, чем ссылка Attachment?

enter image description here

Мой код XPage:

<xe:dynamicViewPanel id="dynamicViewPanel2"
    pageName="#{empty sessionScope.formName ? 'QuickResponseCode.xsp' : sessionScope.formName}"
var="viewEntry" customizerBean="com.cascorp.UserProfileViewCustomizer">
  <xp:eventHandler event="onColumnClick" submit="true"
    refreshMode="complete" id="Attachment">
        <xp:this.action><![CDATA[# {javascript:sessionScope.hideAdd="Yes";
           var srlNbr = viewEntry.getColumnValue("serialNbr");
           var url="/qr/?"+srlNbr;
            context.redirectToPage(url);}]]></xp:this.action>
   </xp:eventHandler>
   <xp:eventHandler event="onColumnClick" submit="true"refreshMode="complete" id="edit"> 
        <xp:this.action><![CDATA[#{javascript: "I think something goes here" ]]></xp:this.action> </xp:eventHandler>
     <xp:this.facets>
         <xp:pager layout="Previous Group Next" partialRefresh="true" id="pager2" xp:key="footerPager">  </xp:pager>
        <xe:pagerSaveState id="pagerSaveState1" xp:key="viewTitle"</xe:pagerSaveState>
        <xp:pager layout="Previous Group Next" partialRefresh="true" id="pager1" 
        xp:key="headerPager"></xp:pager>
    </xp:this.facets>
    <xe:this.data>
        <xp:dominoView var="view1"
databaseName="#{configBean.UserprofilesDbPath}" viewName="#{empty 
sessionScope.viewName ? 'attachmentsbyowner' : sessionScope.viewName}"
keys="# 
    {javascript:session.getEffectiveUserName();}">
   </xp:dominoView>
  </xe:this.data>
</xe:dynamicViewPanel>

Мой видНастройка кода:

package com.cascorp;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.openntf.xsp.debugtoolbar.beans.DebugToolbarBean;
import com.ibm.xsp.extlib.component.dynamicview.UIDynamicViewPanel;
import com.ibm.xsp.extlib.builder.ControlBuilder.IControl;
import om.ibm.xsp.extlib.component.dynamicview.DominoDynamicColumnBuilder.DominoViewCustomizer;
import 
com.ibm.xsp.extlib.component.dynamicview.UIDynamicViewPanel.DynamicColumn;
import com.ibm.xsp.extlib.component.dynamicview.ViewDesign.ColumnDef;

public class UserProfileViewCustomizer  extends DominoViewCustomizer {
//this is used to customize the DynamicViewPanels used in the Order 
Processing views

//@SuppressWarnings("unchecked")
  @Override
  public void afterCreateColumn(FacesContext context, int index,
      ColumnDef colDef, IControl column) {
      //Get a map of the session variables to read the view session scope variable
      //Map svals = context.getExternalContext().getSessionMap();
      //Create a variable for the current component
      UIComponent columnComponent = column.getComponent();
      //Create a reference to the column and set the links to open in read mode
      DynamicColumn dynamicColumn = (DynamicColumn) columnComponent;
      //To have every view open the selected documents in read mode add the following
      dynamicColumn.setOpenDocAsReadonly(true); 
      DebugToolbarBean.get().info("name of column " + dynamicColumn.getColumnName());
      /*
       * If all you need to do is have the views open in read mode instead of
       * edit mode then the above code is all you need.
       * If you want to customize the view columns the the follow code can be
       * used as an example.     
      */

      if (dynamicColumn.getColumnName().equalsIgnoreCase("Attachment")){
          //make it a link
          dynamicColumn.setDisplayAs("link");
          DebugToolbarBean.get().info("make Attachment Column a link");
      }
      if (dynamicColumn.getColumnName().equalsIgnoreCase("edit")){
          //make it a link
          dynamicColumn.setDisplayAs("link");
          DebugToolbarBean.get().info("make edit Column a link");
      }

      //Set column properties for specific views.

      //if (svals.containsValue("processforkkit")) {

        //Hide the first column in this view
        if(dynamicColumn.getColumnName().equalsIgnoreCase("$2")){
          dynamicColumn.setRendered(false);

        }
      if (colDef.isCategorized() ){
          //set the expand and collapse images if the column is categorized
          DebugToolbarBean.get().info("column is categorized: " + dynamicColumn.getColumnName());
        //  ExtendedColumnDef extColDef = (ExtendedColumnDef) colDef;
         // DebugToolbarBean.get().info("twistie image: " + extColDef.twistieImage);
          UIDynamicViewPanel.DynamicColumn col = (UIDynamicViewPanel.DynamicColumn)column.getComponent();
         col.setExpandedImage("expand.png");
         col.setCollapsedImage("collapse.png");
          DebugToolbarBean.get().info("collapsed image: " + col.getCollapsedImage());
          DebugToolbarBean.get().info("expanded image: " + col.getExpandedImage());
          DebugToolbarBean.get().info("style class: " + col.getStyleClass());
          col.setStyleClass("category_col");
      }
       super.afterCreateColumn(context, index, colDef, column);
  }
}

1 Ответ

0 голосов
/ 06 декабря 2018

Я использовал повторный контроль. Смотрите ниже:

<tbody>
<xp:repeat id="repeat1" var="rowData" indexVar="ind" value="#{view1}"
    rows="10" repeatControls="true">
    <tr>
        <td>
            <xp:text escape="false"> </xp:text>
        </td>
        <td>
            <!--Create a link  -->
            <xp:link escape="true" text="#{rowData.Attachment}" id="link2"
                value="#{configBean.HostURL}qr?#{rowData.serialNbr}">
            </xp:link>
        </td>
        <td>
            <xp:text escape="true" id="computedField6" value="#{rowData.serialNbr}">
            </xp:text>
        </td>
        <td>
            <xp:text escape="true" id="computedField2" value="#{rowData.modelNbr}">
            </xp:text>
        </td>
        <td>
        <!-- CREATE A 2ND LINK -->
            <xp:link escape="true" id="link3" text="${langBean.labelEdit}">
                <xp:this.value><![CDATA[#{javascript:importPackage(com.cascorp);
hostName = configBean.getValue("HostCommon")
dbName = configBean.getValue("UserprofilesDbPath")
try{ if(rowData.isDocument()){
    return "MyProfileAttachment.xsp?databaseName="+hostName+"!!"+dbName+"&documentId="+rowData.getUniversalID()+"&action=editDocument"
}
} catch (e) {
return e.toString()
}}]]>
</xp:this.value>
            </xp:link>
        </td>
    </tr>
</xp:repeat>

...