PTC FlexPLM rfa 客制化参考手册 By Elegant.Prosper

1.根据Key或者中文名称,获取单一列表的对应中文名称或Key
<%!
    public String GetValueByKey(String Key){
        try{
            //准备关键字和值的转换
            FlexTypeAttribute LoadAtt=FlexTypeCache.getFlexTypeFromPath("Document\\Images Page").getAttribute("pageType");
            Collection pathData = LoadAtt.getAttValueList().getDataSet();            
            for(Iterator iter=pathData.iterator();iter.hasNext();){
                FlexObject fo=(FlexObject)iter.next();
                String key=fo.getString("KEY");
                String disp=fo.getString("VALUE_ZH_CN");
                if(key.contains(Key))
                    return disp;
            }
            return "";
        }
        catch(Exception e){
            System.out.println("GetValueByKey====Error:"+e);
            return "";        
        }
    }
%>
2.FlexPLM CSP开发 绑定创建新文档和设计师上传文档时候的品牌、季节、年份、系列字段
View Code
  1 <%-- Copyright (c) 2002 Life Cycle Solutions, Inc.   All Rights Reserved --%>
  2 
  3 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
  4 <%-- //////////////////////   onLoad  PAGE DOCUMENTATION    //////////////////////////////--%>
  5 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
  6 <%--
  7     JSP Type: ClientSidePlugin
  8 
  9     product_onloadEvent_CSP.jsp:   // Replace with actual filename //
 10   
 11 --%>
 12 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
 13 <%-- //////////////////////////////// JSP HEADERS ////////////////////////////////////////--%>
 14 <%-- /////////////////  Add to the import package/class list as required  ////////////////--%>
 15 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
 16 <%@page language="java"
 17        import="com.lcs.wc.client.Activities,                
 18                 com.lcs.wc.client.web.*,    
 19                 com.lcs.wc.util.*,
 20                 com.lcs.wc.db.*,
 21                 com.lcs.wc.flextype.*,
 22                 com.lcs.wc.foundation.*,
 23                 com.lcs.wc.product.*,
 24                 com.lcs.wc.placeholder.*,
 25                 com.lcs.wc.season.*,
 26                 com.lcs.wc.sourcing.*,
 27                 com.lcs.wc.specification.*,
 28                 com.liz.wc.util.*,
 29                 wt.part.WTPartMaster,
 30                 java.util.*"
 31 %>
 32 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
 33 <jsp:useBean id="productModel" scope="request" class="com.lcs.wc.product.LCSProductClientModel"/>
 34 <jsp:useBean id="seasonProductModel" scope="request" class="com.lcs.wc.season.LCSSeasonProductLinkClientModel" />
 35 <%-- //////////////////////////////// BEAN INITIALIZATIONS ///////////////////////////////--%>
 36 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
 37 
 38 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
 39 <%-- ///////////////////// INITIALIZATION JSP CODE and CSP environment ///////////////////--%>
 40 <%-- ///// This section is generic and is included in all the Client Side Plugins ////////--%>
 41 <%-- ////// Do not alter this section unless instructed to do so via the comments  ///////--%>
 42 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
 43 <%     
 44 
 45     String activity = request.getParameter("activity");
 46     String action = request.getParameter("action");
 47     String oid = request.getParameter("oid");
 48     String type = request.getParameter("type");
 49     System.out.println(">>>oid>>>>"+oid);
 50     String flexTypeLabel = "";
 51     String flexTypePath = "";
 52 
 53     // The following print out line are provided for debugging
 54     //System.out.println("onLoad..type = " + type);   
 55     //System.out.println("onLoad...activity = " + activity);   
 56     //System.out.println("onLoad...action = " + action);   
 57     
 58     ClientSidePluginHelper csph = new ClientSidePluginHelper();
 59     csph.init(type);
 60     String flextypeName = csph.getFlexTypeName();
 61     System.out.println(">>>flextypeName>>>>"+flextypeName);
 62     
 63     //FlexType flextype = csph.getFlexType();
 64     //csph.listKeyElements();
 65     //csph.listKeyLabels();
 66     //csph.listKeyVariableTypes();
 67     
 68     // if required add java code after this line 
 69     FlexTypeAttribute seasonOptionsAtt = null;
 70     Collection seasonDataSet = null;
 71      String yearName = "";
 72     String season_zh = "";
 73     String seasonKey = "";
 74     String brand = "";
 75     String series = "";
 76     try{
 77         seasonOptionsAtt = FlexTypeCache.getFlexTypeFromPath("Business Object\\Common Attribute Lists\\EP System Attributes").getAttribute("seasonCode");
 78         seasonDataSet = seasonOptionsAtt.getAttValueList().getDataSet();
 79         }catch(Exception ex){
 80             ex.printStackTrace();
 81     }
 82      //Changed By JackChain 2012-09-11
 83      if(FormatHelper.hasContent(oid)&&oid.indexOf("LCSProduct")>-1){
 84         LCSProduct productAVer = (LCSProduct)LCSQuery.findObjectById(oid);
 85         LCSProduct latestProductVersion = (LCSProduct)VersionHelper.getVersion(productAVer.getMaster(),"A");
 86         SeasonProductLocator seasonProductLocator = new SeasonProductLocator();
 87         LCSSeasonProductLink seasonProductLink = seasonProductLocator.getSeasonProductLink(latestProductVersion);
 88         LCSSeason season = (LCSSeason)seasonProductLocator.getSeasonRev(seasonProductLink);
 89         String seasonName = ""+season.getName();
 90         yearName = seasonName.substring(seasonName.indexOf("-")+1,seasonName.lastIndexOf("-")).trim();
 91         season_zh = seasonName.substring(seasonName.lastIndexOf("-")+1,seasonName.length()).trim();
 92            for(Iterator iter = seasonDataSet.iterator();iter.hasNext();){
 93                  FlexObject object = (FlexObject)iter.next();
 94                  String value_CN = (String)object.getString("VALUE_ZH_CN");    
 95                  if(FormatHelper.hasContent(value_CN)&& value_CN.equals(season_zh)){
 96                            seasonKey = (String)object.getString("KEY");
 97                  }
 98           }
 99        brand = ""+latestProductVersion.getValue("EPAplanbrand");
100        series = ""+latestProductVersion.getValue("EPAplanmarketSeries");
101      }
102      else if(FormatHelper.hasContent(oid)&&oid.indexOf("LCSSourceToSeasonLink")>-1){
103         LCSSourceToSeasonLink sourceToSeasonLink = (LCSSourceToSeasonLink) LCSQuery.findObjectById(oid);    
104         System.out.println(">>>sourceToSeasonLink>>>>"+sourceToSeasonLink);
105         LCSSourcingConfig sourcingConfig = (LCSSourcingConfig)VersionHelper.latestIterationOf(sourceToSeasonLink.getSourcingConfigMaster());
106         long productARevId = new Double(sourcingConfig.getProductARevId()).longValue();
107         LCSProduct productAVer = (LCSProduct)LCSQuery.findObjectById("VR:com.lcs.wc.product.LCSProduct:" + productARevId);
108         LCSProduct latestProductVersion = (LCSProduct)VersionHelper.getVersion(productAVer.getMaster(),"A");
109         SeasonProductLocator seasonProductLocator = new SeasonProductLocator();
110         LCSSeasonProductLink seasonProductLink = seasonProductLocator.getSeasonProductLink(latestProductVersion);
111         LCSSeason season = (LCSSeason)seasonProductLocator.getSeasonRev(seasonProductLink);
112         String seasonName = ""+season.getName();
113         yearName = seasonName.substring(seasonName.indexOf("-")+1,seasonName.lastIndexOf("-")).trim();
114         season_zh = seasonName.substring(seasonName.lastIndexOf("-")+1,seasonName.length()).trim();
115 
116            for(Iterator iter = seasonDataSet.iterator();iter.hasNext();){
117                  FlexObject object = (FlexObject)iter.next();
118                  String value_CN = (String)object.getString("VALUE_ZH_CN");    
119                  if(FormatHelper.hasContent(value_CN)&& value_CN.equals(season_zh)){
120                            seasonKey = (String)object.getString("KEY");
121                  }
122           }
123         brand = ""+latestProductVersion.getValue("EPAplanbrand");
124         series = ""+latestProductVersion.getValue("EPAplanmarketSeries");
125      }
126     
127    if(FormatHelper.hasContent(oid)&&oid.indexOf("FlexSpecToSeasonLink")>-1){
128     FlexSpecToSeasonLink specToSeasonLink = (FlexSpecToSeasonLink)LCSQuery.findObjectById(oid);    
129     System.out.println(">>>specToSeasonLink>>>>"+specToSeasonLink);
130     if(specToSeasonLink!=null){
131             WTPartMaster seasonMaster = specToSeasonLink.getSeasonMaster();
132             FlexSpecification spec = (FlexSpecification)VersionHelper.latestIterationOf(specToSeasonLink.getSpecificationMaster());
133             LCSSourcingConfigMaster sourcingConfigMaster = (LCSSourcingConfigMaster)spec.getSpecSource();
134             
135             SeasonProductLocator seasonProductLocator = new SeasonProductLocator();
136             LCSProduct product = seasonProductLocator.getProductARev(sourcingConfigMaster);
137             LCSSeason season = (LCSSeason)VersionHelper.latestIterationOf(seasonMaster);
138             //System.out.println(">>>season="+season);
139             String seasonName = ""+season.getName();
140                  yearName = seasonName.substring(seasonName.indexOf("-")+1,seasonName.lastIndexOf("-")).trim();
141                  //System.out.println(">>>yearName="+yearName);
142                  season_zh = seasonName.substring(seasonName.lastIndexOf("-")+1,seasonName.length()).trim();
143            //System.out.println(">>>season_zh="+season_zh);
144            for(Iterator iter = seasonDataSet.iterator();iter.hasNext();){
145                  FlexObject object = (FlexObject)iter.next();
146                  String value_CN = (String)object.getString("VALUE_ZH_CN");    
147                  if(FormatHelper.hasContent(value_CN)&& value_CN.equals(season_zh)){
148                            seasonKey = (String)object.getString("KEY");
149                  }
150           }
151        brand = ""+product.getValue("EPAplanbrand");
152        series = ""+product.getValue("EPAplanmarketSeries");
153             
154         }
155    }
156      
157        System.out.println(">>>brand>>>"+brand);
158        System.out.println(">>>series>>>"+series);
159        System.out.println(">>>seasonKey>>>"+seasonKey);
160 %>
161 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
162 <%-- /////////////////////////////////////// JSP METHODS /////////////////////////////////--%>
163 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
164 <%! 
165     public static final String JSPNAME = "ClientSidePlugin";
166     public static final boolean DEBUG = true;
167 
168 %>
169 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
170 <%-- ///////////////////////////////// JAVSCRIPT PLUGIN LOGIC ////////////////////////////--%>
171 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
172 
173 <script>
174 
175     // ***** Begining of function pattern *************************************************
176    function onLoadCreateProductImageAttributes(){
177     
178         if("<%= csph.getKeyElement("EPAyear") %>" != "cspKeyNotFound"&&
179                 "<%= csph.getKeyElement("EPAstyleSeries") %>" != "cspKeyNotFound"&&
180                 "<%= csph.getKeyElement("EPAbrand") %>" != "cspKeyNotFound"&&
181            "<%= csph.getKeyElement("EPAseasonType") %>" != "cspKeyNotFound" )
182         {
183             var epYear = document.MAINFORM.<%= csph.getKeyElement("EPAyear")%>;
184             var epSeasonType = document.MAINFORM.<%= csph.getKeyElement("EPAseasonType")%>;
185             var epBrand = document.MAINFORM.<%= csph.getKeyElement("EPAbrand")%>;
186             var epSeries = document.MAINFORM.<%= csph.getKeyElement("EPAstyleSeries")%>;
187             
188             for(h=0;h<epSeries.length;h++){
189                   var valueh = epSeries[h].value;
190                   
191                   if(valueh =='<%=series%>'){
192                       epSeries[h].selected = true;
193                       epSeries.disabled = true;
194                   }
195             }
196             
197             for(l=0;l<epBrand.length;l++){
198                   var valuel = epBrand[l].value;
199                   //alert(">>valueI>>>"+valueI);
200                   if(valuel =='<%=brand%>'){
201                       epBrand[l].selected = true;
202                       epBrand.disabled = true;
203                   }
204             }
205             
206             for(i=0;i<epYear.length;i++){
207                   var valueI = epYear[i].value;
208                   //alert(">>valueI>>>"+valueI);
209                   if(valueI =='<%=yearName%>'){
210                       epYear[i].selected = true;
211                       //epYear.readOnly = true;
212                       epYear.disabled = true;
213                   }
214             }
215             
216             for(k=0;k<epSeasonType.length;k++){
217                  var valuek = epSeasonType[k].value;
218                  //alert(">>>valuek>>>"+valuek);
219                  if(valuek =='<%=seasonKey%>'){
220                       epSeasonType[k].selected = true;
221                       //epSeasonType.readOnly = true;
222                       epSeasonType.disabled = true;
223                   }
224             }
225         }else{        
226            alert(" Error Running CSP function [doThisFunction]" + "\r" +
227                  " one of the flextype keyNames being used is not valid." + "\r" + "\r" +
228                  " Keys Referenced are: attributeKeyname1, attributeKeyname2." 
229                  );
230         }
231        
232    }
233 
234 // ***** End of function pattern *************************************************
235 
236     function runLoadFunctions(){ 
237         //newFunction();
238         onLoadCreateProductImageAttributes();
239     }
240 
241 
242 </script>
243 
244 <script>runLoadFunctions();</script>
245 
246 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
247 <%-- /////////////////////// End of onLoad Client Side Plugin ////////////////////////////--%>
248 <%-- /////////////////////////////////////////////////////////////////////////////////////--%>
3.FlexPLM rfa 获取用户的中文名字,获取用户,根据用户获取用户信息
public String GetChineseName(String loginame){
        try{
            PreparedQueryStatement statement = new PreparedQueryStatement();
            statement.appendFromTable("WTUSER");
            statement.appendSelectColumn("WTUSER", "NAME");
            statement.appendSelectColumn("WTUSER", "IDA2A2");
            statement.appendAndIfNeeded();
            statement.appendCriteria(new Criteria("WTUSER", "NAME", loginame, Criteria.EQUALS));
            SearchResults Result = LCSQuery.runDirectQuery(statement);
            Vector VectRlt = Result.getResults();
            if(VectRlt.size()<=0)
                return loginame;
            else{
                FlexObject user = (FlexObject)VectRlt.get(0);
                Hashtable userIdNameTable=UserCache.getAllUserIDHashtable();
                return userIdNameTable.get(user.getString("WTUSER.IDA2A2")).toString();
            }
        }catch(Exception e)
        {
            return loginame;
        }
}
4.FlexPLM rfa 开jsp自动检测,编译功能

什么意思呢?FlexPLM我们在做客制化开发的时候,往往要对jsp做大量的修改,这样修改的jsp,如果不开启这项自动感知,访问的时候还是以前的jsp页面,怎么开启呢? 找到:D:\ptc\Windchill_9.1\Tomcat\conf目录,修改web.xml文件的如下位置即可:

    <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>development</param-name>
            <param-value>true这里,默认是false</param-value>
        </init-param>

持续更新中...

原文地址:https://www.cnblogs.com/qidian10/p/2673801.html