Theme By © roboweed
random words at night

“seperti permainan papan catur
mengadu pion, bermain strategi
diiringi sepatah dua kata penghibur suasana
langkah-nya pelan, lawan-nya bertahan lalu menyerang
detik waktu pemikiran berjalan
bukan mengalah atau kalah
hanya berbeda, menurut kamu atau aku
sejenak menghela rasa yang biasa semua orang rasa
senang atau tidak, semua ada masa-nya”


2 months ago / 0 notes
2013: the official beginning of the comeback!

Lots of hopes and wishes for this year, these list below are mine,

1. Being A Permanent Employee

2. Having a House

3. Get Married

4. Certified JLPT(Japanese Language Proficiency Test) Level 4

5. Being Independent as a Software Engineer(Being a freelancer for my leisure time project is a good one to explore my skills and knowledge)

6. Go to South Korea or Japan!

7. Weight gain, at least 60-62 kilos

8. Have a public website, Mark Z. has facebook then I had to have one too…

9. Mastering these Frameworks: JSF, Tapestry 5, Hibernate, Spring, Yii, Rails and other technologies that happening in 2013

10. I wish I had a MacBook! Amin….

Bonus:

11. I wanna try some online business, have no idea what kind of business, but I am looking forward to have one….

4 months ago / 0 notes
SMS Gateway Using Gammu and Kalkun
10 months ago / 0 notes
12 months ago / 0 notes
Categorization Web Frameworks

source: http://java.dzone.com/articles/categorization-web-frameworks

1 year ago / 0 notes
1 year ago / 0 notes
JSF 2.1 POM and Web.xml Configuration

POM.xml   

<dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1.7</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.1.7</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>bluesky</artifactId>
            <version>1.0.2</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>jboss</id>
            <name>JBoss Maven Repository</name>
            <url>https://repository.jboss.org/nexus/content/groups/public/</url>
        </repository>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>

web.xml

<!DOCTYPE web-app PUBLIC
 ”-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
 ”http://java.sun.com/dtd/web-app_2_3.dtd” >

<web-app>
    <display-name>Archetype Created Web Application</display-name>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <!—Blusky theme for PrimeFaces —>
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>bluesky</param-value>
    </context-param>
   
    <listener>
        <listener-class>
            com.sun.faces.config.ConfigureListener
        </listener-class>
    </listener>
    <!— Listener implementation to handle web application lifecycle events —>
    <listener>
        <listener-class>
            com.sun.faces.application.WebappLifecycleListener
        </listener-class>
    </listener>
    <servlet>
        <servlet-name>FacesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

1 year ago / 0 notes
Yii: CJuiAutoComplete

User.php

public function getDiscountGroup($id){
  $discount_group = DiscountGroup::model()->findByPk($id);
  return $discount_group;
}

_form.php

echo $form->hiddenField($model,’discount_group_id’);
       
$discount_group = $model->getDiscountGroup($model->discount_group_id);

if($discount_group){
    $group_name = $discount_group->group_name;
}       

$this->widget(‘zii.widgets.jui.CJuiAutoComplete’,
                array(
                      ‘name’=>’group_name’,
                      ‘value’=>$group_name,
                      ‘source’=>$this->createUrl(‘user/autocomplete’),
                      ‘options’=>
                       array(
                           ‘showAnim’=>’fold’,
                           ‘select’=>”js:function(user, ui) {
                                 $(‘#group_name’).val( ui.item.value );
                                 $(‘#User_discount_group_id’).val(ui.item.id);
                                 return false;
                           }”
                        ),
                ));

UserController.php

public function actionAutocomplete () {
       
        if (isset($_GET[‘term’])) {
            $criteria=new CDbCriteria;
            $criteria->alias = “m_discount_group”;
            $criteria->condition = “m_discount_group.group_name like ‘” . $_GET[‘term’] . “%’”;
   
            $dataProvider = new CActiveDataProvider(get_class(DiscountGroup::model()), array(‘criteria’=>$criteria,    ));
            $discountgroups = $dataProvider->getData();
           
            $return_array = array();
            foreach($discountgroups as $discountgroup) {
               
                $return_array[] = array(
                        ‘label’=>$discountgroup->group_name,
                        ‘value’=>$discountgroup->group_name,
                        ‘id’=>$discountgroup->discount_group_id,
                );
            }
           
            echo CJSON::encode($return_array);
        }
    }

1 year ago / 0 notes
Spring Framework 3.1 and Hibernate 4

It looks like Spring 3.1  doesn’t support Hibernate Template for Hibernate 4. So I try to figure out how to integrate these two framework, rather than using Hibernate Template, Spring suggest to use Native Hibernate DAO. Based on this post I tried to implement mine …

application-context.xml

<?xml version=”1.0” encoding=”UTF-8”?>
<beans xmlns=”http://www.springframework.org/schema/beans”
       xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
       xmlns:context=”http://www.springframework.org/schema/context”
       xmlns:tx=”http://www.springframework.org/schema/tx”
       xmlns:p=”http://www.springframework.org/schema/p”
       xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd“>
    
    <!— context:property-placeholder location=”classpath:jdbc.properties” / —>
    <context:component-scan base-package=”com.citixplore.daf” />
    
      <bean id=”propertyConfigurer”
        class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
        <property name=”locations”>
            <list>
                <value>classpath:configuration.properties</value>
            </list>
        </property>
    </bean>
    
    <bean id=”dataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”
          p:driverClassName=”${jdbc.driverClassName}”
          p:url=”${jdbc.url}”
          p:username=”${jdbc.username}”
          p:password=”${jdbc.password}”/>
          

    <bean id=”sessionFactory”
        class=”org.springframework.orm.hibernate4.LocalSessionFactoryBean”
        p:dataSource-ref=”dataSource”
        p:configLocation=”classpath:hibernate.cfg.xml”>
        <property name=”packagesToScan” value=”com.citixplore.daf.dao.hibernate”/>
    </bean>
    
    <bean id=”transactionManager” class=”org.springframework.orm.hibernate4.HibernateTransactionManager”
        p:sessionFactory-ref=”sessionFactory” />
    <tx:annotation-driven/>
    
</beans>

BaseDaoImpl.Java

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.citixplore.daf.bean.BaseBean;
import com.citixplore.daf.dao.BaseDao;


public class BaseDaoImpl<T extends BaseBean> implements BaseDao<T> {
   
    @Autowired
    SessionFactory sessionFactory;
   
    private Class<T> type;
     
    public BaseDaoImpl(Class<T> type) {
        super();
        this.type = type;
    }
   
    public void save(T object){
       
        getCurrentSession().persist(object);
    }

    public void update(T object) {
        getCurrentSession().merge(object);
       
    }
   
    public void delete(T object) {
        getCurrentSession().delete(object);
    }
   
    public T get(Long id) {
         return (T) getCurrentSession().get(type, id);
      
    }

   
    public List<T> getAll() {
        return getCurrentSession().createQuery(“FROM “+ this.type.getName()).list();
    }
   
   
    private Session getCurrentSession(){
        return sessionFactory.getCurrentSession();
    }
}

CityDaoTest.Java

import java.util.List;

import junit.framework.Assert;

import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import com.citixplore.daf.bean.City;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { “classpath:application-context.xml” })
public class CityDaoTest {
    private static final Logger logger = Logger.getLogger(CityDaoTest.class);
   
    private City city;
    private String cityName;
   
    @Autowired
    private CityDao cityDao;
   
    @Before
    public void preMethodSetup() {
        cityName = “Surabaya”;
       
        city = new City();
        city.setName(cityName);
        cityDao.save(city);
    }
   
    @After
    public void postMethodTearDown() {
        cityDao.delete(city);
    }
   
    @Test
    @Transactional
    public void testCityGetAll() {
        List<City> cities = cityDao.getAll();
        Assert.assertEquals(1, cities.size());
    }
}

1 year ago / 0 notes
page 1 of 6
dwiardiirawan
D.A.I
Work Smart, Have Fun, Make a Difference!