我有两个任务流,具有页面片段(.jsff)作为视图的任务流A和具有页面(.jspx)的任务流B。他们两个都有界。是否可以从任务流A的视图中发生的任何操作打开该页面(任务流B)?

这是我的情况。我有一个有限的任务流album-task-flow.xml。它具有两个视图album-list.jsff和album-details.jsff。可以交换这些视图。此任务流已添加到af:region中的页面。

视图album-details.xml中包含图像。在每个图像旁边,我都有一个链接。单击该链接后,我必须在新标签中显示该图像,并且必须打开浏览器的“打印选项”对话框。

如何实现此功能?

最佳答案

我创建了album.jspx:

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
          xmlns:cust="http://xmlns.oracle.com/adf/faces/customizable"
          xmlns:pe="http://xmlns.oracle.com/adf/pageeditor">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document id="d1" title="#{applicationScope.navigationContext.currentNavigationModel.currentSelection.title}">
            <af:form id="f1" usesUpload="true">
                <af:pageTemplate viewId="/oracle/webcenter/portalapp/pagetemplates/WF_Template.jspx"
                         value="#{bindings.pageTemplateBinding}" id="pt1">
                    <f:facet name="content">
                        <pe:pageCustomizable id="pageCustomizable1" inlineStyle="width:968px;">
                            <f:facet name="editor">
                                <pe:pageEditorPanel id="pep1"/>
                            </f:facet>
                            <af:panelGroupLayout layout="vertical" id="pgl1">
                                ---
                                <af:region value="#{bindings.albumtaskflow1.regionModel}" id="albumrg"/>
                                ---
                            </af:panelGroupLayout>
                        </pe:pageCustomizable>
                    </f:facet>
                </af:pageTemplate>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>


在此页面上,通过“ albumrg”区域,我添加了一个任务流专辑任务流。该相册任务流添加了两个页面片段作为视图:

<?xml version="1.0" encoding="UTF-8" ?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
  <task-flow-definition id="album-task-flow">
    <default-activity id="__1">album-list</default-activity>
    <managed-bean id="__15">
      <managed-bean-name id="__13">album</managed-bean-name>
      <managed-bean-class id="__14">com.mhis.webfactory.taskflow.album.AlbumManagedBean</managed-bean-class>
      <managed-bean-scope id="__12">pageFlow</managed-bean-scope>
    </managed-bean>
    <view id="album-list">
      <page>/oracle/webcenter/portalapp/pagefragments/taskflow/album/album-list.jsff</page>
    </view>
    <view id="album-details">
      <page>/oracle/webcenter/portalapp/pagefragments/taskflow/album/album-details.jsff</page>
    </view>
    <control-flow-rule id="__2">
      <from-activity-id id="__3">album-list</from-activity-id>
      <control-flow-case id="__4">
        <from-outcome id="__6">goToDetail</from-outcome>
        <to-activity-id id="__5">album-details</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <control-flow-rule id="__7">
      <from-activity-id id="__8">album-details</from-activity-id>
      <control-flow-case id="__10">
        <from-outcome id="__11">goToList</from-outcome>
        <to-activity-id id="__9">album-list</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <use-page-fragments/>
  </task-flow-definition>
</adfc-config>


从此代码中,我们可以看到两个视图:专辑列表和专辑详细信息,并且已定义了托管bean专辑。它还具有两个控制流规则。这些规则用于浏览或交换视图专辑列表和专辑详细信息。

专辑列表包含专辑列表。这是一个基于来自UCM的数据创建的模型。我认为这不是主题的一部分。每个专辑项目都有一个commandLink,通过它可以进入“详细信息”视图。 “详细信息”视图由该颗粒相册的图像的缩略图组成。

我没有给出这两个页面片段的代码。唯一需要的是commandLink驻留在每个图像缩略图的下方,单击该链接将打开一个新的选项卡或窗口。新打开的标签页仅包含该缩略图的放大或原始图像。同样,此时将打开此选项卡时,必须打开浏览器的打印对话框才能打印该页面。我想我使您能够理解我的要求。

这是该commandLink的代码,也是我的解决方案:

<af:iterator value="#{pageFlowScope.album.albumDetailCurrent}" id="i4" var="images" varStatus="parentStatus"
             rows="#{pageFlowScope.album.numberOfAlbumDetailRow}">
    <af:iterator value="#{images}" var="image" id="i5" varStatus="childStatus">
        <af:commandLink styleClass="btnPrint" id="cl10" actionListener="#{pageFlowScope.album.printImage}">
             <f:attribute name="parentStatus" value="#{parentStatus.index}"/>
             <f:attribute name="childStatus" value="#{childStatus.index}"/>
         </af:commandLink>
    </af:iterator>
</af:iterator>


图像缩略图被封装到List>的数据结构中。

现在,我做了另一个任务流程。这是任务流B,即专辑打印任务流。

<?xml version="1.0" encoding="UTF-8" ?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
  <task-flow-definition id="album-printtask-flow">
    <default-activity id="__1">album-detail-print</default-activity>
    <managed-bean id="__4">
      <managed-bean-name id="__3">albumPrint</managed-bean-name>
      <managed-bean-class id="__6">com.mhis.webfactory.taskflow.album.AlbumPrintManagedBean</managed-bean-class>
      <managed-bean-scope id="__5">pageFlow</managed-bean-scope>
    </managed-bean>
    <view id="album-detail-print">
      <page id="__2">/oracle/webcenter/portalapp/pages/album-detail-print.jspx</page>
    </view>
  </task-flow-definition>
</adfc-config>


从代码中我们可以看到此任务流具有一个jspx页面,即默认的相册-detail-print.jspx页面,还具有一个名为albumPrint的托管bean。

我需要的是在新标签页中打开此任务流。因此,从上述commandLink的actionListener中,我做到了:

public void printImage(ActionEvent event) {
        String taskflowDocument = "/WEB-INF/album-printtask-flow.xml";
        String taskflowId = "album-printtask-flow";
        Integer parentStatus = (Integer)event.getComponent().getAttributes().get("parentStatus");
        Integer childStatus = (Integer)event.getComponent().getAttributes().get("childStatus");
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("image", getAlbumDetailCurrent().get(parentStatus).get(childStatus));
        Map<String, Object> params = new HashMap<String, Object>();
        String taskflowURL = ControllerContext.getInstance().getTaskFlowURL(false,new TaskFlowId(taskflowDocument,taskflowId),params);
        FacesContext context = FacesContext.getCurrentInstance();
        ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
        StringBuilder script = new StringBuilder();
        script.append("window.open(\""+taskflowURL+"\");");
        service.addScript(FacesContext.getCurrentInstance(), script.toString());
}


这将在新选项卡中打开album-detail-print.jspx。以下代码来自album-detail-print.jspx:

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document id="d1" title="Print">
            <af:resource type="javascript" source="/js/js/jquery-1.7.1.min.js"/>
            <af:form id="f1">
                <af:image source="http://#{facesContext.externalContext.request.serverName}/file/#{pageFlowScope.albumPrint.image.docName}&amp;Rendition=Web" id="i3" shortDesc="#{pageFlowScope.albumPrint.image.title}"/>
            </af:form>

            <af:resource type="javascript">
                $(document).ready(function () {
                    window.print();
                });
            </af:resource>
        </af:document>
    </f:view>
</jsp:root>


这是AlbumPrintManagedBean:

package com.mhis.webfactory.taskflow.album;

import com.mhis.portal.backing.main.JSFUtils;

import com.mhis.webfactory.taskflow.album.model.Image;

import java.util.List;

import java.util.Map;

import javax.faces.context.FacesContext;

import javax.servlet.http.HttpSession;

public class AlbumPrintManagedBean {
    private Image image;

    public AlbumPrintManagedBean() {
        super();
        image = (Image)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("image");
    }

    private String jym="JYM";

    public void setImage(Image image) {
        this.image = image;
    }

    public Image getImage() {
        return image;
    }
}

10-07 14:26