Monthly Archives: June 2014


OWL Carousel integration with AngularJS

To up to work owl carousel (or other jQuery plugin) with AngularJS you need to perform some actions.
1. Download and include all plugin files:

    <link href="css/style.css" rel="stylesheet"/>
    <link href="vendor/owl-carousel/owl.carousel.css" rel="stylesheet"/>
    <link href="vendor/owl-carousel/owl.theme.css" rel="stylesheet"/>

    <script src="vendor/jquery.min.js"></script>
    <script src="vendor/owl-carousel/owl.carousel.js"></script>

2. Create directive in AngularJS:

app.directive('wrapOwlcarousel', function () {
    return {
        restrict: 'E',
        link: function (scope, element, attrs) {
            var options = scope.$eval($(element).attr('data-options'));

3. Place new tag in your page:

<wrap-owlcarousel class="owl-carousel" 
    data-options="{autoPlay: 5000, stopOnHover: true, 
        slideSpeed : 300, paginationSpeed : 400, singleItem : true}">
        <img src="img/1.jpg"/>
        <img src="img/2.jpg"/>

See more about OWL Carousel.

Run multiple bat files from single bat file

Windows batch file allows to run another batch file inside of it. There are 2 common way to do it:
1. Using CALL command:

2. Using START command:

The difference between them is the START command runs asynchronously, i.e. it doesn’t wait for finishing previous execution!
Instead of CALL command which is ok for sequential execution.

Thanx to

Using binding in JSF

You may heard about binding term in JSF. But it can be used?
Binding can be involved in validation procedure.

1. Add form to JSF page:

    <h:inputText id="email" 
        binding="#{SomeBaen.emailComponent}" />
    <h:message for="email" />

    <h:commandButton value="Check" action="#{SomeBaen.doCheck}" />

2. Create bean:

public class SomeBean implements Serializable {
    private static final long serialVersionUID = 1L;
    private String emailValue;
    private UIComponent emailComponent;
    public String doCheck() {
        if (isValid(emailValue)) {
            return "ok";
        // set invalid message
        FacesMessage message = new FacesMessage("Invalid email");
        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(emailComponent.getClientId(context), message);
        return null;
    public void setEmailValue(String emailValue) {
        this.emailValue = emailValue;
    public String getEmailValue() {
        return emailValue;
    public void setEmailComponent(UIComponent emailComponent) {
        this.emailComponent = emailComponent;
    public UIComponent getEmailComponent() {
        return emailComponent;

So, if validation failed you’ll see a message near inputText control.
Also example

Passing command line arguments to ant script file

You may know such ant task as Input –
It promts user to enter some stuff. But what if you want to run script without promt but using command line arguments only?
Ant presents the awesome solution: just use -D option!
See more at

Consider we have ant script run.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<project name="someProject" default="someTask" basedir=".">
    <taskdef resource="net/sf/antcontrib/antlib.xml" />

    <target name="someTask">
        <input message="Enter first argument" addproperty="arg.first" />
        <input message="Enter second argument" addproperty="arg.second" />
        <!-- your code here... -->
        <copy file="arg.first" tofile="${arg.second}" />

To run it in batch mode use:

  ant -buildfile run.xml someTask -Darg.first=111.txt -Darg.second=111_copy.txt

Thanx to

Primefaces ajax update on rendered attribute

If you are using rendered attribute on some component and want to update it on ajax request, you be noticed error.
So, that is normal because if rendered=”false” – this component will not be added to DOM tree.
That’s why it cannot be found on update callback.

For more info see

To fix the problem wrap component into another container and make update on it.
For ex.

<p:outputPanel id="containerToUpdate">
    <p:panel rendered="#{SomeBean.isOk}">
        <!-- your code here -->

<p:commandButton update="containerToUpdate"/>

Thanx to

Read version of package from META-INF in Java JSF Bean

Often you need to show the software version in JSF page.
How to make it as follows:

1. Create JSF Bean

public class PropertiesBean implements Serializable {

    private static final long serialVersionUID = 8607941655014578684L;

    private static final String METAINF_LOCATION = "META-INF/MANIFEST.MF";
    private static final String VERSION_PREFIX = "Implementation-Version: ";
    private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+\\.\\d+\\.\\d+)");
    public String getVersion() {
        try {
            InputStream is = null;
            Scanner scanner = null;
            try {
                is = this.getClass().getClassLoader().getResourceAsStream(METAINF_LOCATION);
                scanner = new Scanner(is);
                while (scanner.hasNext()) {
                    String line = scanner.nextLine();
                    if (line.startsWith(VERSION_PREFIX)) {
                        Matcher matcher = VERSION_PATTERN.matcher(line);
                        if (matcher.find()) {
                            String group =;
                            return group;
            } finally {
                if (scanner != null) {
                if (is != null) {
        } catch (Exception e) {
            // TODO: log error!
        return null;

2. Register bean in faces-config.xml


3. Use it on JSF page:

<h:outputText value="[v#{PropertiesBean.version}]" rendered="#{PropertiesBean.version != null}" />


See also,