private void encode(UIInput year, UIInput month, UIInput day, LocalDate localDate) { if (localDate == null) { return; } year.setValue(normalize(localDate.getYear())); month.setValue(normalize(localDate.getMonthOfYear())); day.setValue(normalize(localDate.getDayOfMonth())); }
private void encode( UIInput year, UIInput month, UIInput day, UIInput hour, UIInput min, Date date) { if (date == null) { return; } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); year.setValue(normalize(calendar.get(Calendar.YEAR))); month.setValue(normalize(calendar.get(Calendar.MONTH) + 1)); day.setValue(normalize(calendar.get(Calendar.DAY_OF_MONTH))); hour.setValue(normalize(calendar.get(Calendar.HOUR_OF_DAY))); min.setValue(normalize(calendar.get(Calendar.MINUTE))); }
public UIInput getManipulateMode() { if (manipulateMode == null) { manipulateMode = new HtmlInputHidden(); manipulateMode.setValue(Constants.DISPLAY_MOD); } return manipulateMode; }
private void encode( UIInput year, UIInput month, UIInput day, UIInput hour, UIInput min, LocalDateTime localDateTime) { if (localDateTime == null) { return; } year.setValue(normalize(localDateTime.getYear())); month.setValue(normalize(localDateTime.getMonthOfYear())); day.setValue(normalize(localDateTime.getDayOfMonth())); hour.setValue(normalize(localDateTime.getHourOfDay())); min.setValue(normalize(localDateTime.getMinuteOfHour())); }
public static void switchAddImageIntoForm(String formName, String fileName) { FacesContext context = FacesContext.getCurrentInstance(); UIInput txtImageName = (UIInput) context.getViewRoot().findComponent(formName + ":txtImageName"); txtImageName.setValue(fileName); txtImageName.setSubmittedValue(fileName); context.renderResponse(); }
/* (non-Javadoc) * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp() */ public void setUp() throws Exception { super.setUp(); form = new HtmlForm(); form.setId("form"); form2 = new HtmlForm(); form2.setId("form2"); facesContext.getViewRoot().getChildren().add(form); facesContext.getViewRoot().getChildren().add(form2); stp1 = (UISimpleTogglePanel) application.createComponent("org.richfaces.SimpleTogglePanel"); stp1.setId("simpleTogglePanel1"); stp1.setOpened(true); stp1.setSwitchType(UISimpleTogglePanel.SERVER_SWITCH_TYPE); openMarker1 = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE); openMarker1.setId("openMarker"); openMarker1.setValue("open"); closeMarker1 = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE); closeMarker1.setId("closeMarker"); closeMarker1.setValue("close"); stp1.getFacets().put(openMarker1.getId(), openMarker1); stp1.getFacets().put(closeMarker1.getId(), closeMarker1); form.getChildren().add(stp1); stp2 = (UISimpleTogglePanel) application.createComponent("org.richfaces.SimpleTogglePanel"); stp2.setId("simpleTogglePanel2"); stp2.setOpened(false); stp2.setSwitchType(UISimpleTogglePanel.SERVER_SWITCH_TYPE); openMarker2 = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE); openMarker2.setId("openMarker"); openMarker2.setValue("open"); closeMarker2 = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE); closeMarker2.setId("closeMarker"); closeMarker2.setValue("close"); stp2.getFacets().put(openMarker2.getId(), openMarker2); stp2.getFacets().put(closeMarker2.getId(), closeMarker2); form2.getChildren().add(stp2); input = (UIInput) application.createComponent(UIInput.COMPONENT_TYPE); input.setValue(""); input.setId("opened"); input.getAttributes().put("onchange", "return true;"); stp1.getChildren().add(input); command = new HtmlCommandLink(); command.setId("command"); stp1.getChildren().add(command); }
public static void clearSubmittedValues(UIComponent uiComponent) { if (uiComponent == null) { return; } Iterator<UIComponent> children = (uiComponent).getFacetsAndChildren(); while (children.hasNext()) { clearSubmittedValues(children.next()); } if (uiComponent instanceof UIInput) { ((UIInput) uiComponent).setSubmittedValue(null); ((UIInput) uiComponent).setValue(null); ((UIInput) uiComponent).setLocalValueSet(false); ((UIInput) uiComponent).resetValue(); } }
// validates the form to find any errors regarding the user input // "never trust any user" public void validate(ComponentSystemEvent event) { UIForm form = (UIForm) event.getComponent(); UIInput pw1 = (UIInput) form.findComponent("password1"); UIInput pw2 = (UIInput) form.findComponent("password2"); UIInput zipCode = (UIInput) form.findComponent("zip"); UIInput accountNo = (UIInput) form.findComponent("accountNo"); UIInput bankCode = (UIInput) form.findComponent("bankCode"); // check if a password has been entered if (pw1 == null || pw1.getValue() == null) { FacesContext fc = FacesContext.getCurrentInstance(); fc.renderResponse(); return; } // check further that both passwords are equal // if not, a message should be shown to the user telling him // that both passwords do not match if (!(pw1.getValue().equals(pw2.getValue()))) { pw1.setValue(""); pw2.setValue(""); FacesContext fc = FacesContext.getCurrentInstance(); ResourceBundle bundle = fc.getApplication().getResourceBundle(fc, "m"); message.setText( bundle.getString("register_passwordDifferent"), bundle.getString("register_passwordDifferentDetail"), FacesMessage.SEVERITY_ERROR, pw1.getClientId()); fc.renderResponse(); } String zip = (String) zipCode.getValue(); if (zip.length() > 8 || zip.length() < 4) { zipCode.setValue(""); FacesContext fc = FacesContext.getCurrentInstance(); ResourceBundle bundle = fc.getApplication().getResourceBundle(fc, "m"); message.setText( bundle.getString("register_zipError"), null, FacesMessage.SEVERITY_ERROR, zipCode.getClientId()); fc.renderResponse(); } String accountNumber = (String) accountNo.getValue(); if (accountNumber.length() > 12 || accountNumber.length() < 5) { accountNo.setValue(""); FacesContext fc = FacesContext.getCurrentInstance(); ResourceBundle bundle = fc.getApplication().getResourceBundle(fc, "m"); message.setText( bundle.getString("register_accountNoError"), null, FacesMessage.SEVERITY_ERROR, accountNo.getClientId()); fc.renderResponse(); } String bankcode = (String) bankCode.getValue(); if (bankcode.length() > 7 || bankcode.length() < 5) { bankCode.setValue(""); FacesContext fc = FacesContext.getCurrentInstance(); ResourceBundle bundle = fc.getApplication().getResourceBundle(fc, "m"); message.setText( bundle.getString("register_bankCodeError"), null, FacesMessage.SEVERITY_ERROR, bankCode.getClientId()); fc.renderResponse(); } }