Tuesday, March 17, 2015

Fix DB Network Adapter could not establish

Fist, make sure you configure listener.ora correctly:

# listener.ora Network Configuration File: C:\Oracle\Database\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\Oracle\Database\product\11.2.0\dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:C:\Oracle\Database\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 301KhiemTT-W7)(PORT = 1521))

    )
  )

ADR_BASE_LISTENER = C:\Oracle\Database

Run lsnrctrl start to start Listener.

Hope that help!

Monday, March 16, 2015

Receive parameter from AJAX call in Liferay

One very important thing you should noted is set these property in portlet definition (in liferay-portlet.xml) at the end of <portlet> tag:

<add-default-resource>true</add-default-resource>

and

<requires-namespaced-parameters>false</requires-namespaced-parameters>

under <icon> tag.

If not, you can not get parameter's value out in  Portlet Implementation.

Liferay Scheduler

Very good Liferay Scheduler post:
http://itsliferay.blogspot.com/2012/08/implement-scheduler-in-liferay-61.html
https://liferayazam.wordpress.com/2012/06/10/create-a-scheduler-in-liferay-6/
http://pmkathiria.blogspot.com/2013/06/how-to-write-simplecron-scheduler-in.html

Thursday, March 12, 2015

Get autoId from sequence in Oracle when insert data

CREATE SEQUENCE <sequence_name> START WITH 1 INCREMENT BY 1;

INSERT INTO Customers (AutoId, CustomerName, Country)
SELECT <sequence_name>.NEXTVAL, SupplierName, Country FROM Suppliers

Friday, March 6, 2015

Using servlet in Liferay portlet

Create a simple Servlet:

public class MyServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;
   
    public MyServlet() {
        super();
    }

    public void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        System.out.println("inside servlet");
    }

}


In web.xml, add:

    <servlet>
        <servlet-name>My Servlet</servlet-name>
        <servlet-class>com.example.servlet.MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>My Servlet</servlet-name>
        <url-pattern>/myServlet</url-pattern>
    </servlet-mapping>


Remember url path to servlet is: /plugin-context-path/myServlet, not just /myServlet.