Java Code Examples for org.apache.wicket.markup.html.form.FormComponent#getInput()

The following examples show how to use org.apache.wicket.markup.html.form.FormComponent#getInput() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MinMaxPoolSizeValidator.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void validate(Form form) {
	// we have a choice to validate the type converted values or the raw
	// input values, we validate the raw input
	final FormComponent formComponent1 = components[0];
	final FormComponent formComponent2 = components[1];

       String s1 = formComponent1.getInput();
       String s2 = formComponent2.getInput();

       // disabled components
       if ( (s1 == null) || s1.trim().equals("") || (s2 == null) || s2.trim().equals("")) {
       	error(formComponent2, resourceKey() + "." + "notnull"); 
       }  else  {
       	Integer i1 = Integer.parseInt(s1);
       	Integer i2 = Integer.parseInt(s2);
       	if (i1.intValue() > i2.intValue()) {
       		error(formComponent2, resourceKey() + "." + "invalid");
       	}           
       }
}
 
Example 2
Source File: DaysValidator.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void validate(Form form) {
	// we have a choice to validate the type converted values or the raw
	// input values, we validate the raw input
	final FormComponent formComponent1 = components[0];
	final FormComponent formComponent2 = components[1];

       String s1 = formComponent1.getInput();
       String s2 = formComponent2.getInput();

       // disabled components
       if ( (s1 == null) && (s2 == null)) {
          return; 
       }

       // must have one and only one selected
       if ("".equals(s1) && "".equals(s2)) {
           error(formComponent2, resourceKey() + "." + "bothnull");
       }  else if (!"".equals(s1) && !"".equals(s2)) {
           error(formComponent2, resourceKey() + "." + "bothnotnull");
       }
}
 
Example 3
Source File: TimeInputValidator.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void validate(Form form) {
	// we have a choice to validate the type converted values or the raw
	// input values, we validate the raw input
	final FormComponent formComponent1 = components[0];
	final FormComponent formComponent2 = components[1];

       String s1 = formComponent1.getInput();
       String s2 = formComponent2.getInput();

       if ((s1 == null) || (s2 == null) || "".equals(s1) || "".equals(s2)) {
           return;
       }

       if (comparator.compare(s1, s2) >= 0 ) {                        
           Map<String, Object> params = new HashMap<String, Object>();
           params.put("first", s1);
           params.put("second", s2);
           error(formComponent2, resourceKey(), params);
       }
}
 
Example 4
Source File: PasswordValidator.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void validate(Form form) {
    // we have a choice to validate the type converted values or the raw
    // input values, we validate the raw input
    final FormComponent formComponent = components[0];

    String s = formComponent.getInput();

    if (s == null) {
        return;
    }

    s = passwordEncoder.encodePassword(s, null);

    try {            
        User user = securityService.getUserByName(NextServerSession.get().getUsername());
        if (!user.getPassword().equals(s)) {
            error(formComponent, resourceKey() + "." + "oldPasswordInvalid");
        }
    } catch (Exception e) {
        // TODO
        e.printStackTrace();
    }


}
 
Example 5
Source File: InputChangeBehavior.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onUpdate(AjaxRequestTarget target) {
	FormComponent<?> component = (FormComponent<?>) getComponent();

	// IE triggers "input" event when the focused on the search input even if nothing is 
	// input into search box yet. To work around this issue, we compare search string 
	// against previous value to only update the branches table if there is an actual 
	// change.
	String newInput = component.getInput();
	if (!Objects.equals(newInput, input)) {
		input = newInput;
		onInputChange(target);
	}
}
 
Example 6
Source File: MailServerValidator.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public void validate(Form form) {
    final FormComponent formComponent1 = components[0];
    final FormComponent formComponent2 = components[1];
    final FormComponent formComponent3 = components[2];

    String ip = formComponent1.getInput();
    String port = formComponent2.getInput();
    String from = formComponent3.getInput();

    // disabled components
    if ((ip == null) && (port == null) && (from == null)) {
        return;
    }

    if ("".equals(ip)) {
        if (!"".equals(port) || !"".equals(from)) {
            error(formComponent1, resourceKey() + "." + "ip");
        }
    }
    if ("".equals(port)) {
        if (!"".equals(ip) || !"".equals(from)) {
            error(formComponent2, resourceKey() + "." + "port");
        }
    }
    if ("".equals(from)) {
        if (!"".equals(ip) || !"".equals(port)) {
            error(formComponent2, resourceKey() + "." + "from");
        }
    }

}