Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeFaces editor

How to make the text aligned from right to left(p:editor) by default.

Currently using primefaces 3.0.M2-SNAPSHOT. Cannot update to newer version now?

This is required for Arabic version of application.

Thanks

like image 221
techie2k Avatar asked Jan 06 '13 19:01

techie2k


2 Answers

add an entry in the web.xml like

<context-param>
    <param-name>primefaces.DIR</param-name>
    <param-value>RTL</param-value>
</context-param>

and then by default any primefaces component will render the text from right to left

REF: http://blog.primefaces.org/?p=2283

like image 189
Rafay Avatar answered Sep 28 '22 06:09

Rafay


Not All PrimeFaces components have the attribute "dir" and since you're not using version 3.5, you cannot use the application scope DIR parameter. So basically, you have two choices:

  • Apply a tricky CSS class dynamically to a component that does not have DIR attribute. Something like

    .rtlclass { float: right; /* etc */ }

    or

dirClass property gets its values depending on the view locale. If Arabic, then the getter returns "rtlClass", otherwise "ltrCLass".

If by chance the PrimeFaces component has the DIR attribute, in a bean write something like :

public class FacesBean {

private String direction = "";

public FacesBean(){}

// Getter & setter

public String getDirection() {
        if (FacesContext.getCurrentInstance().getViewRoot().getLocale()
                .getLanguage() == "ar") {
            direction = "RTL";
        } else {
            direction = "LTR";
        }
        return direction;
    }

}

and in your xhtml file:

<p:component dir="#{facesBean.direction}" ..... />
like image 24
Hanynowsky Avatar answered Sep 28 '22 07:09

Hanynowsky