Friday, December 9, 2016

Jetty - Maven Hot Deploy

  1. Edit pom.xml, Add scanIntervalSeconds element to allow jetty scanning changes in contextPath

  2.  <plugin>  

  3. Then compile only your modified class.

Friday, June 24, 2016

Thursday, October 29, 2015

Setting width Inplace Component Primefaces

In an hour ago I have a  problem with inplace component then Aceh Gayo coffee was gave me the idea.

taken from

There is no properties for setting width in inplace component, but if you look at html code that produced by primefaces you will find the span element for wrapping the text in inplace component.

Then you just need little html knowledge to setting span width in other words is inplace width.
Here the code :

 <p:inplace id="inOutput4" editor="true" style="display:inline-block;width:250px;overflow:hidden">  
   <p:inputText id="output4" value="#{bean.output}" required="true" />  

Yes, I use style="display:inline-block;width:250px;overflow:hidden"  for set the width.

Saturday, October 10, 2015

Jsf, Getting url parameter value

Source image:
Good morning, people!
Have you drink your coffee today? I'm drinking a cup of americano from nearby store. :)

Let say you have to get param value in http://localhost:8080/apps/faces/test.xhtml?param=hello.
All you need is just add view param in your xhtml file and mapped it with a variable in managed bean.

xhtml Code :
     <f:viewParam name="param" value="#{testBean.message}" />  

Managed Bean Code :
 @ManagedBean(name = "testBean")  
 public class TestBean implements Serializable {  
   private String message;  
   public String getMessage(){  
     return message;  
   public String setMessage(String message){  
     this.message = message;  

Saturday, September 26, 2015

Securing Web Application in Tomcat 7 using jdbc realm and j_security_check

Use case : 

a Web Application contains master and transaction modules. Those modules need to be secured using Admin role.

Implementation :

  1.  Prepare database table, we can use either table or view. The following script is the minimum requirement, we can use either table and view.

       (      "ID" NUMBER(5,0) NOT NULL ENABLE,   
             "USER_ID" VARCHAR2(50 BYTE) NOT NULL ENABLE,   
             "ROLE_NAME" VARCHAR2(20 BYTE),   
              PRIMARY KEY ("ID")  

  3. Configure $CATALINA_HOME /conf/server.xml, add the following :

     <Realm className="org.apache.catalina.realm.JDBCRealm" connectionName="ORACLE_SCHEMA" connectionPassword="ORACLE_PASSWORD"  
      connectionURL="jdbc:oracle:thin:@localhost:1521:xe" driverName="oracle.jdbc.driver.OracleDriver"   
      dataSourceName="jdbc/authority" userTable="USER_MANAGEMENT" userNameCol="USER_ID" userCredCol="PASSWORD"  
      roleNameCol="ROLE_NAME" userRoleTable="USER_MANAGEMENT"   

    short explanation about the configuration :
    • className is the JDBCRealm class. When we use glassfish, it must be different
    • connectionName is oracle schema's name
    • connectionPassword is  oracle schema's password
    • connectionURL is the jdbc oracle thin url that contains ip or machine name, port and SID of Oracle Server.
    • driverName is JDBC Driver
    • dataSourceName is data source name, the name will be used later on.
    • userTable is table or view, this is the database table that we created before (USER_MANAGEMENT). Container will look up to this table for checking user privilege.
    • userNameCol is a column for storing user id in the application.
    • userCredCol is a column for storing password of user id in the application.
    • userRoleTable is a table or view for storing the role of the application. To make this simple we'll use the same table as userTable, in the real world we could use different table or view.
    • roleNameCol is a column on the USER_MANAGEMENT table. This column let container knows the role of user id.
  4. Configure web.xml
    • Define security constrain:
                      <web-resource-name>Master and transaction</web-resource-name>  
    • Define security role
    • login-config

  5. Put your JDBC driver into Tomcat lib directory : $CATALINA_HOME/lib/
  6. Restart tomcat and publish the apps

Wednesday, September 2, 2015