Total Pageviews

2006/09/27

[JavaScript] How to do trim() in JavaScript

<body onload="test()">

<script>

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function test() {

var str = " a ";

alert("Original string: '" + str + "'");

str = str.trim();

alert("Incompletely stripped string: '" + str + "'");

}

</script>



reference
http://www.bigbold.com/snippets/posts/show/701

[JavaScript] How to do trim() in JavaScript

<body onload="test()">

<script>

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function test() {

var str = " a ";

alert("Original string: '" + str + "'");

str = str.trim();

alert("Incompletely stripped string: '" + str + "'");

}

</script>

2006/09/08

[Windchill] How to generate mData

Steps.
1. open rose
2. Tools --> Windchill --> System Generation
3. Click OK

Troubleshoot
It may show generation refuse error in the progress of system generation
Error: wt.templateutil.processor.DefaultTemplateProcessor is not Extendable, so cannot extend it.

Solution
1. Open user.properties (under /Codebase)
2. add one attribute wihch named
wt.generation.overrideNonExtendableClasses, and add classes which we want to do extend. If we have multiple classes need to do extend, sperate them by comma.

ex. wt.generation.overrideNonExtendableClasses=wt.templateutil.processor.DefaultTemplateProcessor,wt.templateutil.processor.FormTaskDelegate
After you add them to user.properties, you can see this kind of warning message, it means you had successfully finished system generation.
Warning: wt.templateutil.processor.DefaultTemplateProcessor is not Extendable, but is being allowed as a backward compatible override

2006/08/27

[Mail] commons-mail 亂碼問題

[常見問題1]sent出去的mail的中文標題變成亂碼

呼叫setCharset此方法,設定編碼方式為UTF-8
public void setCharset(java.lang.String newCharset)
http://jakarta.apache.org/commons/email/api-release/org/apache/commons/mail/Email.html#setCharset(java.lang.String)



[常見問題2]sent出去的mail的中文內文便成亂碼

呼叫setContent此方法,第一個參數給予訊息內容,第二個參數給予conent type,例如text/plain;charset=UTF-8
public void setContent(java.lang.Object aObject,
java.lang.String aContentType)
http://jakarta.apache.org/commons/email/api-release/org/apache/commons/mail/Email.html#setContent(java.lang.Object,%20java.lang.String)


[常見問題3]sent出去的附件中文檔名變成亂碼

在EmailAttachment的物件中的setName方法中,使用MimeUtility的encodeText方法
attachment.setName(MimeUtility.encodeText("中文訊息", "UTF-8", null));

http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeUtility.html

2006/08/11

[InfoEngine] Remember to get newOid as you want to update-object


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<ie:unit>
 <ie:webject name="CheckOut-Objects" type="ACT">
  <ie:param name="INSTANCE" data="windchill"/>
  <ie:param name="AUTHORIZATION" data="${@server[]authorization[0]}"/>
  <ie:param name="OBJECT_REF" data="<%=objRef%>"/>
  <ie:param name="GROUP_OUT" data="checkoutDoc"/> 
 </ie:webject>

 <%

 Group checkoutDoc = getGroup("checkoutDoc");;
 String newOid = (String)checkoutDoc.getAttributeValue(0, "obid");
 System.out.println("Checkout Document ends... Update begin, new id");
 System.out.println(newOid);
 %>

 <ie:failure>
 <%System.out.println("no document had been CheckOut");%>
 </ie:failure>

 <ie:success>
 <% System.out.println (getGroup("checkoutDoc").getElementCount() + " document(s) 
 had been CheckOut"); %>
 </ie:success>

</ie:unit> 

<ie:unit>
 <ie:webject name="Update-Objects" type="ACT">
  <ie:param name="INSTANCE" data="windchill"/>
  <ie:param name="GROUP_OUT" data="updateDoc"/>
  <ie:param name="ATTRIBUTE" data="IBA|Revise_By_Drawing"/>
  <ie:param name="OBJECT_REF" data="<%=newOid%>"/>
  <ie:param name="TYPE" data="wt.doc.WTDocument"/>
  <ie:param name="FIELD" data="IBA|Revise_By_Drawing='N'"/> 
  <ie:param name="AUTHORIZATION" data="${@server[]authorization[0]}"/>
 </ie:webject>

 <ie:failure>
  <%System.out.println("no document had been update");%>
 </ie:failure>

 <ie:success>
  <% System.out.println (getGroup("updateDoc").getElementCount() + " document(s) had been updated"); %>
 </ie:success>
</ie:unit>

<ie:unit>

 <ie:webject name="CheckIn-Objects" type="ACT">
  <ie:param name="INSTANCE" data="com.ptc.vm-ase.Windchill"/>
  <ie:param name="ATTRIBUTE" data="IBA|Revise_By_Drawing"/>
  <ie:param name="GROUP_OUT" data="checkInDoc"/>
  <ie:param name="AUTHORIZATION" data="${@server[]authorization[0]}"/>
  <ie:param name="TYPE" data="wt.doc.WTDocument"/>
  <ie:param name="OBJECT_REF" data="<%=newOid%>"/>
 </ie:webject>

 <ie:failure>
  <%System.out.println("no document had been checked-in");%>
 </ie:failure>

 <ie:success>
  <% System.out.println (getGroup("checkInDoc").getElementCount() + " document(s) had been checked-in"); %>
 </ie:success>

</ie:unit>

[InfoEngine] Where to find the compiled InfoEngine Task

You can find the Java files and class files under:
<Windchill_HOME>\tasks\codebase\com\infoengine\compiledTasks


2006/07/04

[SVN] mod_dav_svn.so is garbled- perhaps this is not an Apache module DSO

Error Message
httpd: Syntax error on line 115 of D:/Program Files/Apache Software Foundation/Apache2.2/conf/httpd.conf: API module structure `dav_svn_module' in file D:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_dav_svn.so is garbled- perhaps this is not an Apache module DSO?


Resolution
Owning to the apache version is 2.2, it will report this kind of error message. Just change the apache version to 2.0, then this kind of error will disappear.

2006/06/06

[Windchill] Build ResourceBundle How-To

If I edit some texts in reportResource.rbInfo, how do I build this resource bundle.

Steps.
1. open windchill shell window
2. utilize ResourceBuild
Example Usage: ResourceBuild D:\ptc\Windchill\src\wt\fc or ResourceBuild wt.fc.fcResource
--Arg1 specifies which directory or class to generate.
--Arg2 specifies if locale specific resource will be built.
--values for arguments not passed will be obtained from tools.properties.

then input the command as bellows:
ResourceBuild ext.fusheng.report.reportResource true

execution info:
D:\ptc\Windchill>echo off
CLASSPATH=
file:/D:/ptc/Windchill/codebase/
file:/D:/ptc/Windchill/srclib/SystemGeneration.jar
file:/D:/ptc/Windchill/srclib/WindchillUtil.jar
file:/D:/ptc/Windchill/srclib/CommonXml.jar
file:/D:/ptc/Windchill/srclib/CommonCore.jar
file:/D:/ptc/Windchill/srclib/Modules.jar
file:/D:/ptc/Windchill/srclib/JGL.jar
file:/D:/ptc/Windchill/srclib/xmlParserAPIs.jar
file:/D:/ptc/Windchill/srclib/xercesImpl.jar
file:/D:/ptc/Windchill/srclib/dom4j.jar
file:/D:/ptc/Windchill/srclib/SystemGeneration_L10N.jar
file:/D:/ptc/Windchill/srclib/WindchillUtil_L10N.jar
file:/D:/ptc/Windchill/srclib/CommonXml_L10N.jar
file:/D:/ptc/Windchill/srclib/CommonCore_L10N.jar
Update ResourceInfos = false
Build ResourceBundles = true
Process Locales = en_US,en_GB,fr,de,es,ja,it,ko,zh_CN,zh_TW

ext.fusheng.report.reportResource
Warning: com.sun.tools.javac.Main cannot be loaded, using external compiler instead
Execution/Launch Time = 4.0 seconds

2006/06/02

[HTML / JS] View formatted source (format source extension)

https://addons.mozilla.org/firefox/697/

Displays formatted and color-coded source and optional CSS information for each element.

You can see exactly which CSS rules match for an element. The rules are displayed including file name and line number. The topmost element is that with the highest priority.

You can fold/unfold/hilite block elements (table, tr, td, div, span,...). Really cool feature: select a block level element of interest directly in the page and view it's source! To help you to quickly analyze the source code you can view images directly from the source and add comments to folded block elements. The code view is based on the rendered document, so you will also see dynamically (by Javascript) created and modified html elements! Works also with frames and selected text.

2006/05/31

[Windchill] Cannot do copy & paste in Applet

Scenario
As I do some operation in Windchill, because of some user interface was done by applet, it is inconvenience for us if we wolud like to copy some texts then paste them into the applet.

Solution
It is the security constraints so we cannot do copy and paster in applet window.
We can find out the java.policy file in JRE\lib\security, then append this declaration as bellows:

grant codeBase "http://hostname/Windchill/-" {
permission java.security.AllPermission;
};

[Windchill] IE, IE, IE Affects PTC SW

reference: http://worldcadaccess.typepad.com/blog/2006/05/ie_ie_ie_affect.html

PTC notes that This issue affects all releases of Windchill and Windchill-based solutions, including Windchill PDMLink, Windchill ProjectLink, Windchill Foundation & PDM, Windchill DynamicDesignLink, and Pro/INTRALINK 8.0 and higher; ProductView clients may also be affected. Some of the problems include:
- Loading the Java plug-in from an updated Microsoft browser may cause it to exit prematurely.
- Launching ProductView Standard Edition plug-in from an updated browser may cause it to become unresponsive.

For more info, check this Web page [ptc.com].