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
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
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}" ..... />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With