Monday, August 31, 2015

Grep files from file list

Following Linux script can be used to grep files from file list. Suppose you have file name list in "test2" file. Then, you can use following script to grep files in current location and copy these files to "/home/sujith/files/.

for k in `cat /home/sujith/test2`; 
do echo $k; 
cp *$k /home/sujith/files/.;

String Substring Linux

Suppose file "test" has strings with "-" separator. If you need to get the second part of the string into "test2" file, you can use the following command.




cat test |awk -F"-" '{print $2}' > test2

Monday, August 24, 2015

Insert URL in PDF using iReport

You can add a URL into your PDF file using following iReport xml file. PDF will show "Click Here!" text and URl will redirect to "".

<textField hyperlinkType="Reference" hyperlinkTarget="Blank">
<reportElement x="5" y="5" width="200" height="15"/>
<textFieldExpression class="java.lang.String"><![CDATA["Click Here!"]]></textFieldExpression>

Access Referenced Managed Bean in JSF

Following code can be used to reference one manged bean from another.

public class UsingBean 
    private NeededBean neededBean;

    public NeededBean getNeededBean()
    return neededBean;

    public void setNeededBean(NeededBean neededBean)
    this.neededBean = neededBean;

Now, you can use the following methods to call referenced managed bean property in JAVA class.

ELContext elContext = FacesContext.getCurrentInstance().getELContext();
NeededBean neededBean 
    = (NeededBean) FacesContext.getCurrentInstance().getApplication()
    .getELResolver().getValue(elContext, null, "neededBean");

---------------------------------- or --------------------------------------------

FacesContext facesContext = FacesContext.getCurrentInstance();
NeededBean neededBean
    = (NeededBean)facesContext.getApplication()

Reference site :-