<h:panelGrid columns="6" id="pnlDetails">
<p:outputLabel value="Locale:" for="cboLocale" />
<p:selectOneMenu id="cboLocale" value="#{calculatorController.language}" style="width:200px" required="true">
<f:selectItems value="#{calculatorController.languages}" />
<p:ajax update="pInputText" process="@this"/>
</p:selectOneMenu>
<p:outputLabel value="RTL:" for="chkRtl" />
<p:selectBooleanCheckbox id="chkRtl" value="#{calculatorController.rtl}">
<p:ajax update="pInputText" process="@this"/>
</p:selectBooleanCheckbox>
<p:outputLabel value="Calc:" for="pInputText" />
<p:inputText id="pInputText" value="#{calculatorController.pInputText}">
<pe:calculator dir="#{calculatorController.rtl ? 'rtl' : 'ltr'}" locale="#{calculatorController.language}" showOn="both"/>
</p:inputText>
</h:panelGrid>
@Named
@ViewScoped
public class CalculatorController implements Serializable {
private static final long serialVersionUID = 20120224L;
private BigDecimal hInputText;
private BigDecimal pInputText;
private BigDecimal pInputNumber = new BigDecimal("0.00");
private String language = "fr";
private boolean rtl = false;
public List<SelectItem> getLanguages() {
final List<SelectItem> results = new ArrayList<>();
results.add(new SelectItem("ms", "Bahasa Melayu (Malaysian)"));
results.add(new SelectItem("ca", "Català (Catalan)"));
results.add(new SelectItem("da", "Dansk (Danish)"));
results.add(new SelectItem("de", "Deutsch (German)"));
results.add(new SelectItem("es", "Español (Spanish)"));
results.add(new SelectItem("fr", "Français (French)"));
results.add(new SelectItem("hr", "Hrvatski jezik (Croatian)"));
results.add(new SelectItem("it", "Italiano (Italian)"));
results.add(new SelectItem("nl", "Nederlands (Dutch)"));
results.add(new SelectItem("no", "Norsk (Norwegian)"));
results.add(new SelectItem("pl", "Polski (Polish)"));
results.add(new SelectItem("pt_BR", "Português (Portuguese/Brazilian)"));
results.add(new SelectItem("ru", "\u0420\u0443\u0441\u0441\u043a\u0438\u0439 (Russian)"));
results.add(new SelectItem("sl", "Slovenski Jezik (Slovenian)"));
results.add(new SelectItem("sr", "\u0421\u0440\u043f\u0441\u043a\u0438 (Serbian)"));
results.add(new SelectItem("tr", "Türkçe (Turkish)"));
results.add(new SelectItem("uk", "\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430 (Ukrainian)"));
results.add(new SelectItem("zh_CN", "\u4e2d\u6587 (\u7b80\u4f53) (Chinese, Simplified)"));
results.add(new SelectItem("zh_TW", "\u6b63\u9ad4\u4e2d\u6587 (\u7e41\u9ad4) (Chinese, Traditional)"));
return results;
}
public void closeListener(final CloseEvent closeEvent) {
final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Close fired",
"Component id: " + closeEvent.getComponent().getId());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public void openListener(final OpenEvent openEvent) {
final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Open fired",
"Component id: " + openEvent.getComponent().getId());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public void buttonListener(final ButtonEvent buttonEvent) {
final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Button fired",
"Name: " + buttonEvent.getName() + " Value: " + buttonEvent.getValue());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public BigDecimal gethInputText() {
return hInputText;
}
public void sethInputText(final BigDecimal hInputText) {
this.hInputText = hInputText;
}
public BigDecimal getpInputText() {
return pInputText;
}
public void setpInputText(final BigDecimal pInputText) {
this.pInputText = pInputText;
}
public BigDecimal getpInputNumber() {
return pInputNumber;
}
public void setpInputNumber(final BigDecimal pInputNumber) {
this.pInputNumber = pInputNumber;
}
public String getLanguage() {
return language;
}
public void setLanguage(final String language) {
this.language = language;
}
public boolean isRtl() {
return rtl;
}
public void setRtl(final boolean rtl) {
this.rtl = rtl;
}
}