<%@page contentType="text/html;charset=UTF-8" pageEncoding="ISO-8859-1" session="true"
%><%@page errorPage="AdminException.jsp"
%><%@page import="com.fujitsu.iflow.model.workflow.WFSession"
%><%@page import="com.fujitsu.iflow.model.util.URLEncoder"
%><%@page import="com.fujitsu.iflow.model.wfcore.WFAdminSessionImpl"
%><%@page import="com.fujitsu.iflow.model.workflow.DMSEntityValue"
%><%@page import="com.fujitsu.iflow.model.workflow.ProcessInstance"
%><%@page import="java.util.Enumeration"%>
<%@page import="java.util.Hashtable"
%><%@page import="com.fujitsu.iflow.model.bpm.BPMAdmin"
%><%@page import="com.fujitsu.iflow.model.bpm.BPMSession"
%><%@page import="com.fujitsu.iflow.model.bpmcore.BPMAdminImpl"
%><%
    request.setCharacterEncoding("UTF-8");request.getParameterNames(); //Need dummy call for WL9.1
    BPMSession bps = (BPMSession) session.getAttribute("BPMSession");
    if (bps == null) {
        %><jsp:include page="PasswordPanel.jsp" flush="true"/><%
        return;
    }

    BPMAdmin bpas = bps.getAdmin();
    WFAdminSessionImpl wfSession = ((BPMAdminImpl)bpas)._wfas;

    String processId = request.getParameter("processId");
    if (processId == null) {
        processId = (String) session.getAttribute("processId");
    }
    long id = Long.parseLong(processId);

    String[] bcolor = {"evenrow","oddrow"};
    int nextColor = 0;
    session.setAttribute("processId",processId);
    session.setAttribute("TabIndex","-1");

    String actionURL = "SaveProcessToXML.jsp";

%>
<html>

<SCRIPT TYPE="text/javascript">

    function nullForm()
    {

        if (document.attachmentForm.XMLFilePath.value == "")
        {
            alert("You need to provide the XML file path!");
            document.attachmentForm.XMLFilePath.focus();
            return false;
        }
    }


    function openDmsBrowser(url)
    {

    var w = '450';
    var h = '400';
    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2;
    var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+'yes'+',';
      settings +='resizable=no';
    var childWindow = window.open(url, "DmsBrowser",settings);
    if (childWindow.opener == null)
        childWindow.opener = self;
    }


    function selectOperation(operation)
    {
       if (document.attachmentForm.XMLFilePath.value == "")
       {
                   alert("You need to provide the XML file path!");
                   document.attachmentForm.XMLFilePath.focus();
                   return false;
        }
       if(operation == 'Save')
       {

          var fileName = document.attachmentForm.XMLFilePath.value;
          document.location.href='SaveProcessToXML.jsp?path=' + fileName;
       }

    }

</SCRIPT>

<head><title>Interstage Business Process Manager | Export Package</title></head>
<jsp:include page="StyleSheet.jsp" flush="true"/>
<script language="javascript" src="styles/clockscripts.js"></script>
</head>
<body class="adminBodyClass">
<jsp:include page="AdminHeader.jsp" flush="true"/>
<br/><br/>


<form name="attachmentForm" enctype="multipart/form-data" method="post" action="<%= actionURL %>" onSubmit="return nullForm();">
<center>


<TABLE border="0" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC" class="tableClass" width="450">
    <tr>
        <td class="headrow">Saving Process Instance(<%= processId %>) As XML File</td>
    </tr>
    <tr>
            <td bgcolor="#FFFFFF" align="center"><br/>XML File Path :
            <input type=text name=XMLFilePath value ="" size=24>
        <input type="button" onClick="openDmsBrowser('AdminDmsBrowser.jsp?process=true')" value="Browse..." class="submitClass">
        <br/><br/></td>

    </tr>
    <tr>
        <td valign="center" align="center" bgcolor="#EEEEEE">
        <input type="button" value="Save" class="submitClass" onClick="selectOperation('Save')">
        </td>
    </tr>
</table>

<p>

<input type=hidden name="ExportSelection" value="">

</form>
</center>
</body>
</html>


<%!
    public WFAdminSessionImpl getiFlowSession(Object modelObject)
    {
            return (WFAdminSessionImpl)(modelObject);
    }



%>
