2010年12月17日 星期五

Save Attachment

I don't know if this is work but just for reference.

///
/// Programmatically Attach document in SPDocument Library
///

void documentAttachmentInSPList()
{
//SPListItem spListItem = null; //write code to get the SPListItem.
//fileUpload is control ID of ASP.Net FileUpload control
if (!string.IsNullOrEmpty(fileUpload.FileName))
{
//Get file extension ( *.doc OR *.docx )
string fileExtension
= fileUpload.FileName.Substring(fileUpload.FileName.IndexOf("."));

//FILENAME is file name visible in SPListItem
//Check file is already added or not. If added then delete it.
for (int i = 0; i < spListItem.Attachments.Count; i++)
{
if ((spListItem.Attachments[i] != null)
&& (spListItem.Attachments[i].Equals("FILENAME" + fileExtension)))
{
spListItem.Attachments.Delete("FILENAME" + fileExtension);
break;
}
}

//Attach the file.
spListItem.Attachments.Add("FILENAME" + fileExtension, fileUpload.FileBytes);

//LISTNAME is SPList's name
//See the attached file as link in user-created custom column.
string attachmentURL = Request.Url.Scheme + "://" + Request.Url.Authority
+ "/Lists/" + "LISTNAME" + "/Attachments/" + spListItem.ID + "/";

spListItem["Attached File"]
= attachmentURL + "FILENAME" + fileExtension + ", View FILE";
}
}

2010年11月17日 星期三

Show Menu on Blank aspx page

Remove from page:
<asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"></asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"></asp:Content>

Find the "PlaceHolderPageImage" and add image:
<asp:Content ContentPlaceHolderId="PlaceHolderPageImage" runat="server"><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></asp:Content>

2010年11月12日 星期五

Get Url for Current page

To Ensure the page is reachable. User:
SPUtility.GetPageUrlPath(HttpContext.Current));

2010年11月11日 星期四

Save Multiple Users into SharePoint List

SPFieldUserValueCollection pmCollection = new SPFieldUserValueCollection();

for...{
SPUser user= SPContext.Current.Site.RootWeb.AllUsers[your username];
SPFieldUserValue UserName = new SPFieldUserValue(web, user.ID, user.ID.ToString());
pmCollection.Add(UserName);
}

SPContext.Current.ListItem[your field name] = pmCollection;

// save item
SaveButton.SaveItem(SPContext.Current, false, string.Empty);
SPContext.Current.ListItem.Update();

2010年11月8日 星期一

Create List Item Menu on Specific List

1. Goto "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES" and create a folder (Exampel: CustomListItemMenu )

2. Create “Feature.xml”


<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="{C7B4AEEE-88D8-46eb-80AB-666228D19280}"
Scope="Web"
Title="Custom Action ***"
Version="1.0.0.0"
Description="Anything you can input">
<ElementManifests>
<ElementManifest Location="MenuItems.xml"/>
</ElementManifests>
</Feature>


3. Create “MenuItems.xml” which can be named anything else as long as you provide appropriate reference in “ElementManifest” section described above. Here is what we’ll have in our “MenuItems.xml”:

<?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Name of the action"
RegistrationType="ContentType"
ShowInLists = "True"
RegistrationId="0x010060E9BA54FF561C4E8F05788698ABF445"
Location="EditControlBlock"
Sequence="101"
Title="Open as Word 2003***"
>
<UrlAction Url="~site/_layouts/CustomAction.aspx?ID={ItemId}& amp;List={ListId}"/>

</CustomAction>

</Elements>

NOTE:
You need to find out
RegistrationType="ContentType" RegistrationId="0x010060E9BA54FF561C4E8F05788698ABF445"

1. Go Setting => List Settings => Advanced Settings
2. Select the Yes radio button on the “Allow management of content types”
3. Click OK
4. On the Setting page. Find the Content Type section and click on "item" or your default content type"
5. Copy the “ctype” value in URL as your RegistrationId
6. Copy this value into the RegistrationId attribute


If you want to do list type. Setting is:

RegistrationType="List"
RegistrationId="100"

RegistrationId = templateID
Go here to find out.



4. The key item in the definition above is to set the “RegistrationId” to the “ListTemplate” value we have taken down earlier. This will ensure the context menu item will be attached only to the types we have specified.

stsadm -o deactivatefeature -name CustomListItemMenu -url http://site -force
stsadm -o uninstallfeature -name CustomListItemMenu -force
stsadm -o execadmsvcjobs


stsadm.exe -o installfeature -name CustomListItemMenu
stsadm.exe -o activatefeature -name CustomListItemMenu -url http://site -force
stsadm -o execadmsvcjobs

iisreset

2010年9月28日 星期二

64 bit: Cannot recycle connection pool

Error:
C:\WINDOWS\SysWOW64>iisapp.vbs /a "SharePoint - 80" /r
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Input Error: Can not find script file "C:\WINDOWS\system32\iisapp.vbs".


Solution:
I copied iisapp.vbs, cmdlib.wsc and iisschlp.wsc over from %WINDIR%\System32 to %WINDIR%\SysWOW64

I registered cmdlib.wsc and iisschlp.wsc using regsvr32 cmdlib.wsc and regsvr32 iisschlp.wsc respectively

2010年8月30日 星期一

Error: Login/Logout not working on Basic Authentication.

Just to add some information for others reading this thread. I only got it working when i switched to a login/logout jspx page and not while using Basic authentication. The adfAuthentication servlet is not able to invalidate the browser session set with Basic authentication. If you follow the steps in chapter 28.5.3 of Fusion Developer’s Guide for Oracle Application Development you should be ok.

From: http://forums.oracle.com/forums/thread.jspa?threadID=835464

Error: Java code in jsp source files is not allowed in ojsp.next mode

One option is: disable ojsp mode.
1. go to Project Property
2. go to ADF View
3. Enable User Customizations
4. check on Across Sessions using MDS

2010年8月19日 星期四

Error: ORA-01005: null password given; logon denied

In your JDeveloper
Click on Module.xml
Click on Configurations
Select ModuleLocal
Click on the Edit button
Change the Connection Type to JDBC DataSource
Redeploy your application to the WLS

2010年8月17日 星期二

Error: You need permission to perform this action

1. Click start windows button
2.click programs
3. click accessories
4. Right Click command prompt and slect run as Adminstrator
5. click continue
6. type in witth out quotes "net user administrator /active:yes
7. enter
8. restart computer

2010年7月30日 星期五

Oracle SOA:Stop and start command

Middleware/user_projects/domains/soa_domain/bin/stopWebLogic.sh &
Middleware/user_projects/domains/soa_domain/bin/stopManagedWebLogic.sh soa_server1 &
Middleware/user_projects/domains/soa_domain/bin/stopManagedWebLogic.sh bam_server1 &


Middleware/user_projects/domains/soa_domain/bin/startWebLogic.sh &
Middleware/user_projects/domains/soa_domain/bin/startManagedWebLogic.sh soa_server1 &
Middleware/user_projects/domains/soa_domain/bin/startManagedWebLogic.sh bam_server1 &

2010年7月15日 星期四

Oracle SOA: Install with error RCU-6107 DB Init Param Prerequisite failure for processes current value

If you have this error:

RCU-6107 DB Init Param Prerequisite failure for processes current value

1. Connect to the database and open SQL*plus
run: SQL> alter system set processes=300 scope=spfile;

2. find a file name: init.ora under "spfile" folder, Change parameter open_cursors=500
and find the config/scripts/initXEtemp.ora , Change parameter open_cursors=500

Weblogic: heap size

Change file setting on C:\Oracle\Middleware\jdeveloper\jdev\bin\jdev.conf
Or just find the file in JDeveloper folder.

2010年7月13日 星期二

DB2: View lock on table and kill session

get snapshot for locks on

LIST APPLICATION

FORCE APPLICATION (13347)

13347 is Application ID.

2010年7月8日 星期四

Connect EJB from other client to Weblogic

Please include following JAR file:
Creating a wlfullclient.jar for JDK 1.6 client applications
Use the following steps to create a wlfullclient.jar file for a JDK 1.6 client application:

Change directories to the server/lib directory.
cd WL_HOME/server/lib
Use the following command to create wlfullclient.jar in the server/lib directory:
java -jar wljarbuilder.jar
You can now copy and bundle the wlfullclient.jar with client applications.
Add the wlfullclient.jar to the client application’s classpath.

Creating a wlfullclient5.jar for JDK 1.5 client applications
Change directories to the server/lib directory.
cd WL_HOME/server/lib
Use the following command to create wlfullclient.jar in the server/lib directory:
java -jar wljarbuilder.jar -profile wlfullclient5
You can now copy and bundle the wlfullclient5.jar with client applications.
Add the wlfullclient5.jar to the client application’s classpath..
(REMEMBER: USE JDK1.5 to generate the jar file)

Refer from http://download.oracle.com/docs/cd/E12840_01/wls/docs103/client/jarbuilder.html#wp1077742

Default URL and username for JDeveloper Integrated Weblogic Server

Here it is:
URL: http://localhost:7101/console
username: weblogic
password: weblogic1

2010年6月3日 星期四

Oracle 11g: Error on Start up

If you get Error like:
Failed to auto-start Oracle Net Listener using xxxxx
or
ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener

SOLUTION:
Update file "dbstart", change link ORACLE_HOME_LISTENER=$1 to ORACLE_HOME_LISTENER=$ORACLE_HOME

2010年5月28日 星期五

DB2: Select table Primary key and Foreign Key

Primary key

SELECT NAME
FROM
SYSIBM.SYSCOLUMNS
WHERE TBNAME = 'table name'
AND TBCREATOR = 'creator'
AND KEYSEQ > 0
ORDER BY KEYSEQ ASC

Foreign Key

SELECT B.REFTBNAME AS PARENTTABLE,COLNAME
FROM
SYSIBM.SYSFOREIGN KEYS A,
SYSIBM.SYSRELS B
WHERE A.RELNAME = B.RELNAME
AND B.TBNAME = 'table name'
AND B.REFTBCREATOR = 'creator'
AND B.REFTBCREATOR = A.CREATOR

2010年5月12日 星期三

SQL: not match from table 1

SELECT TestTable1.ID, TestTable1.Name, TestTable1.Title
FROM TestTable1 LEFT JOIN TestTable ON TestTable1.[Name] = TestTable.[Name]
WHERE (((TestTable.Name) Is Null));

2010年5月11日 星期二

SharePoint: The trial period for this product has expired.

Method 1:
Go to: http://support.microsoft.com/kb/971620/en-us
(When you install the 2007 Microsoft Office servers Service Pack 2, the product expiration date is activated incorrectly) and follow the document.

Method 2:
Added application pool Account ("dcomcnfg.exe") to the Distributed users
(Add the Application Pool account to the built-in Active Directory group "Distributed COM Users".)
1. Go to Application Pool and see what's the account which can access this Application pool.
2. Go to Active Directory and find the group named "Distributed COM Users". Add the application pool account to that group.

2010年4月18日 星期日

JAVA Memory Leak

FINDING MEMORY LEAKS IN JAVA APPS

Here is a small HOWTO on how to find memory leaks with Java SE.

I’ve written it while trying to find memory leaks in our testing tools: JTHarness and ME Framework, and then wanted to share the HOWTO with the world, but I didn’t have my blog at that time, so I posted this info as a comment to a relevant entry in the excellent Adam Bien’s blog.

Note: Use the latest JDK 6, because it has the latest tools, with lots of bug fixes and improvements. All the later examples assume that JDK6’s bin directory is in the PATH.

STEP 1. START THE APPLICATION.

Start the application as you usually do:

java -jar java_app.jar

Alternatively, you could start java with hprof agent. Java will run slower, but the huge benefit of this approach is that the stack traces for created objects will be available which improves memory leak analysis greatly:

 java   -Dcom.sun.management.jmxremote   -Dcom.sun.management.jmxremote.port=9000   -Dcom.sun.management.jmxremote.authenticate=false   -Dcom.sun.management.jmxremote.ssl=false   -agentlib:hprof=heap=dump,file=/tmp/hprof.bin,    format=b,depth=10   -jar java_app.jar

When the application is up, perform various actions that you think might lead to memory leaks.

For example, if you open some documents in your app, the memory graph could rapidly go up. If closing the docs and invocation of full garbage collection did not bring the memory back to normal level, there is probably a leak somewhere.You might use jconsole from JDK 6 to see the memory consumption graph to have a clue whether memory leak is present or not:

jconsole

It will pop up a dialog with a list of Java applications to connect to. Find the one with java_app.jar and connect. Also, jconsole allows to invoke full GC providing nice button just for that.

STEP 2. FIND THE APPLICATION PID.

Find out the application’s process id via:

jps

It will print something like:

15976 java_app.jar
7586 startup.jar
22476 Jps
12248 Main
5437 Bootstrap

In our case the pid is 15976.

STEP 3. DUMP THE HEAP INTO FILE.

Dump heap into the file:

jmap -dump:format=b,file=/tmp/java_app-heap.bin 15976

We just told jmap to dump the heap into /tmp/java_app-heap.bin file, in binary from (which is optimized to work with large heaps). The third parameter is the pid we found in Step 2.

Alternatively, if you started java with hprof agent, you could just use Ctrl-\ on Solaris/Linux or Ctrl-Break on Windows to dump heap into the file, specified in hprof agent arguments.

STEP 4. VISUALIZE THE HEAP.

Use jhat tool to visualize the heap:

jhat -J-Xmx326m /tmp/java_app-heap.bin

Jhat will parse the heap dump and start a web server at port 7000. Connect to Jhat server by pointing your browser to:

http://localhost:7000

And start investigating. :)

Jhat allows you to see what objects are present in the heap, who has references to those objects, etc.

Here are some tips:

  • Investigate _instances_, not _classes_.
  • Use the following URL to see the instances: http://localhost:7000/showInstanceCounts/
  • Use “Reference Chains from Rootset” (Exclude weak refs!!!) to see who’s holding the instance.

2010年3月24日 星期三

Spring: onBindAndValidate

Well, there is a reason why the standard Validator does not offer access to the current HttpServletRequest: Validators are not web-specific in the first place, so they obviously shouldn't have any Servlet API artifacts in their signature. So I'm afraid standard Validators will remain the way they are, without access to the HttpServletRequest.

So in general, I would still recommend to override "onBindAndValidate" here. Note that you can easily delegate to some custom validator objects from there: For example, define a "RequestAwareValidator" interface yourself, implement it according to your needs, pass an instance into your controller through dependency injection, and call that instance from your "onBindAndValidate" implementation.


Refer to http://book.opensourceproject.org.cn/java/eclipse/eclipsejava/opensource/0672328968/ch07lev1sec8.html#ch07fig08

2010年3月3日 星期三

2010年2月19日 星期五

DB2: Select table sturcture

select TBNAME, NAME, COLTYPE, LENGTH, NULLS FROM SYSIBM.SYSCOLUMNS
WHERE TBCREATOR = 'schemaname' and TBNAME in ('tablename')

2010年2月10日 星期三

SVN: Eclipse Plugin

1. Help->Install New Software
2. Choose to work with Galileo – http://download.eclipse.org/releases/galileo
3. Unfold Collaboration
4. Choose Subversive SVN Team Provider (Incubation)
5. I employ you to restart Eclipse and don’t use any plugin at this point since they will not work and you will get a message which is similar to this: 0×0040010b: Obtain Project Name’ operation finished with error: Selected SVN connector library is not available or cannot be loaded …’. Instead you rather install a connector library.
6. Help->Install New Software
7. Add a site
8. I used: http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/ , but you can probably use any other that has SVNKit or JavaHL connector
9. Unfold Subversive SVN Connectors
10. Select Subversive SVN Connectors, SVNKit (1.3.0), JavaHL (1.6.0) and it’s native libraries.
11. Restart Eclipse
12. Configure SVN Connector by specifying the connector in Window->Preferences->Team->SVN->SVN Connector.