Pages

Friday, January 24, 2014

Passing values from Page to Bean in JSF

refer to :
http://gik.firetrot.com/index.php/2013/07/19/passing-values-from-page-to-bean-in-jsf/


There are three ways to pass values from page to JSF ManagedBean:
  1. Passing value with f:param tag – using action attribute
  2. Passing value with f:attribute tag – using actionListener attribute
  3. Passing value with f:setPropertyActionListener tag – no need for additional dealing, value allplies directly to bean property!
example : 
case 1:
<p:commandButton value="Pass Param" action="#{PassParamBean.passParam}">
        <f:param name="someParamHolder" value="THIS is VALUE_OF_PARAM !!!" />    </p:commandButton>

case 2:
<p:commandButton value="Pass Attribute" actionListener="#{PassParamBean.passAttributeListener}"
        ajax="true" update="someAttributeId">
        <f:attribute name="someAttributeHolder" value="THIS is VALUE_OF_ATTRIBUTE !!!" />    </p:commandButton>
case 3: 
 <p:commandButton value="Pass Property"
       ajax="true" update="somePropertyId">
       <f:setPropertyActionListener target="#{PassParamBean.someProperty}" 
           value="THIS is VALUE_OF_PROPERTY !!!" />
</p:commandButton>

in managed  bean:
 package passvalue;

import java.io.Serializable;
import java.util.Map;

import javax.faces.component.UIComponent;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

public class PassParamBean implements Serializable {
    private static final String DEFAULT_OUTCOME = "pass_value";

    private String someParam;
    private String someAttribute;
    private String someProperty;

    public String passParam() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExternalContext externalContext = facesContext.getExternalContext();

        Map<String, String> params = externalContext.getRequestParameterMap();
        someParam = params.get("someParamHolder");

        return DEFAULT_OUTCOME;
    }

    public void passAttributeListener(ActionEvent event) {
        UIComponent component = event.getComponent();
        Map<String, Object> attrs = component.getAttributes();
        someAttribute = (String) attrs.get("someAttributeHolder");
    }

// setters and getters

}

Thursday, January 16, 2014

Install Prosody from source on Centos 6.

https://prosody.im/downloads/source/
https://prosody.im/doc/installing_from_source
https://prosody.im/doc/configure

1. download & extract
wget --no-check-certificate  https://prosody.im/downloads/source/prosody-0.9.2.tar.gz
tar xvf prosody-0.9.2.tar.gz
cd prosody-0.9.2

2. install dependencies
yum install openssl openssl-* lua5.1 liblua5.1-dev libidn11-dev libssl-dev

3. configure & make install
./configure --ostype=PRESET
make install


note : Prosody's configuration is held in a single file, prosody.cfg.lua. on centos 6 you should find it in /usr/local/etc/prosody/prosody.cfg.lua

Install Maven on Linux

http://stackoverflow.com/questions/12076326/how-to-install-maven2-on-redhat-linux

From the command line; you should be able to simply do:
wget http://mirrors.digipower.vn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz
  1. Run command above from the dir you want to extract maven to (e.g. /usr/local/apache-maven)
  2. run the following to extract the tar:
    tar xvf apache-maven-3.0.4-bin.tar.gz
  3. Next add the env varibles such as
    export M2_HOME=/usr/local/apache-maven/apache-maven-3.0.4
    export M2=$M2_HOME/bin
    export PATH=$M2:$PATH
  4. Verify
    mvn -version