2011年9月26日 星期一

JDeveloper: ADF: Custom Converter

1. Create Converter: 

package com.pyramid.misc;

import java.util.Map;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

public class PhoneConverter implements Converter  {
    public PhoneConverter() {
     
    }

    public Object getAsObject(FacesContext facesContext,
                              UIComponent uiComponent, String value) {
      if (value == null || (value.trim().length() == 0))
              {
                  return value;
              }
   
      // format phone numbers to display correctly
   
        String phone = value.trim();
        if (phone.length() == 10) {
            phone = phone.substring(0, 3) + "-" + phone.substring(3, 6) + "-" + phone.substring(6, 10);
        }
        else if (phone.matches("\\d{10}\\s*\\d+")) {
            phone = phone.replaceAll("\\s+", "");
            phone = phone.substring(0, 3) + "-" + phone.substring(3, 6) + "-" + phone.substring(6, 10) + " x" + phone.substring(10);
        }
 
      return phone;
    }

    public String getAsString(FacesContext facesContext,
                              UIComponent uiComponent, Object value) {
        String phoneNumber = (String)value;
         if (phoneNumber == null || (phoneNumber.trim().length() == 0))
          {
              return "";
          }
          String phone = phoneNumber.trim();


          if (phone.length() == 10) {
              phone = phone.substring(0, 3) + "-" + phone.substring(3, 6) + "-" + phone.substring(6, 10);
          }
          else if (phone.matches("\\d{10}\\s*\\d+")) {
              phone = phone.replaceAll("\\s+", "");
              phone = phone.substring(0, 3) + "-" + phone.substring(3, 6) + "-" + phone.substring(6, 10) + " x" + phone.substring(10);
          }
       
        return phone;
    }
}

2. Register on faces-config.xml file (or faces configuration file)
<faces-config
...

     <converter>
    <description>A Converter for phone number</description>
    <converter-id>PhoneConverter</converter-id>
    <converter-class>
        com.pyramid.misc.PhoneConverter
   
</converter>

...
</faces-config>

3. Use in field:


 <af:outputText value="#{row.Phone}" id="ot3">
                       <f:converter converterId="PhoneConverter"/>
                   </af:outputText>
                 

2011年9月20日 星期二

SharePoint 2007: Display Attachment List


Display file links:

foreach (String fileAtt in attachmentsAtt)
{
          String attachmentAbsoluteURL =
          item.Attachments.UrlPrefix // gets the containing directory URL
          + fileAtt;
   // Add ToDo here
}


Get SPFile from Attachment:
SPAttachmentCollection attachmentsAtt = item.Attachments;
 foreach (String fileAtt in attachmentsAtt)
{
             SPFile file = web.GetFile(attachmentsAtt.UrlPrefix + fileAtt);
             // Add ToDo here
}


2011年9月15日 星期四

Glassfish: ReflectPermission suppressAccessChecks error


If you get something like on glassfish:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name '__ContractService': Initialization of bean failed; nested exception is java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)

Go to Admin console => Configurations => [target] => security 
Uncheck Security Manager.

VMWare: Take Ownership Fail

1. GO TO VM/[servername] folder.
2. Delete *.lck

2011年9月12日 星期一

Weblogic: Create new and start up Managed Server


Create a new managed Server
1. Go to console.
2. Click Environment => Servers => New
3. Give a new name and use different port from other servers.
4. Save

Add library into new managed Server:
1. Go to console
2. Click on Deployment => adf.oracle.domain(1.0,11.1.1.0.0) => Target
3. Choose new managed server
4. Save
5. Repeat the 1-4 actions on library:

  • adf.oracle.domain.webapp(1.0,11.1.1.1.0)
  • jsf(1.2,1.2.9.0)
  • jstl(1.2,1.2.0.1)
  • ohw-rcf(5,5.0)
  • ohw-uix(5,5.0)
  • UIX(11,11.1.1.1.0)
  • oracle.adf.dconfigbeans(1.0,11.1.1.0.0)
  • oracle.adf.management(1.0,11.1.1.1.0)
  • oracle.dconfig-infra
  • oracle.jrf.system.filter
  • oracle.jsp.next(11.1.1,11.1.1)
  • oracle.sdp.client(11.1.1,11.1.1)
  • oracle.soa.workflow.wc(11.1.1,11.1.1)
  • oracle.webcenter.framework(11.1.1,11.1.1)
  • oracle.webcenter.framework.view(11.1.1,11.1.1)
  • oracle.webcenter.jive.dependency(11.1.1,11.1.1)
  • oracle.webcenter.skin(11.1.1,11.1.1)
  • oracle.wsm.seedpolicies(11.1.1,11.1.1) – only if you have installed Oracle Webservices Manager.
  • oracle.portlet-producer.jpdk(11.1.1,11.1.1)
  • oracle.portlet-producer.wsrp(11.1.1,11.1.1)
  • DMS application
  • wsm-pm

6. Go to console => Environment/Startup and Shutdown Classes:
7. Choose each item and add target to new managed server.



Start up new server on Windows:
1. Start up the domain
2. Go to %oracle_home%/user_projects/domains/[your domain]/bin
3. Create a shortcut on startManagedWebLogic.cmd on Desktop
4. Go to properties on the shortcut => Shortcut tab
5. Add [manage server name] & into target like C:/..../startmanagedWebLogic.cmd newManagedServer &
6. Double click on Shortcut.


Following is from 

Oracle recommends creating a separate  schema to store custom Webcenter application metadata. Using existing  schemas may corrupt seeded repositories.
  1. Run rcu from RCU_HOME/bin folder. Skip the first screen.
  2. Specify Database connection parameters in the next step.
  3. From “Select Components” screen, specify “ORAFMWSCHOOL” for “Create a new Prefix”. Select Oracle AS Repository Components –> AS Common Schemas –> Metadata Services. Click Next.
  4. Enter schema password and confirm the same.
  5. Click Next and then Finish.
This creates ORAFMWSCHOOL_MDS schema in the database.
Login to Enterprise Manager console using http://localhost:7001/em
Click on “Metadata Repositories” link from left sidebar.
image
Click on “mds-soa” to bring up SOA MDS repository detail screen. From “Metadata Repository” menu under mds-soa, select Administration –> Register/Deregister.
image
From Database Repositories section, click on “Register…”. Enter database details and click on Query.
image
Select ORAFMWSCHOOL_MDS from the list of displayed Metadata Repositories. Enter a Repository Name and Schema password we created in Step 2.
This completes registration of repository with Oracle Weblogic server domain.