Package com.uwyn.rife.site

Examples of com.uwyn.rife.site.ValidationBuilder


{
  public void processElement()
  {
    Template      t = getHtmlTemplate("drone.admin.change_nick");
    FormBuilder      form_builder = t.getBeanHandler().getFormBuilder();
    ValidationBuilder  validation_builder = form_builder.getValidationBuilder();
   
    form_builder.generateField(t, "new_nick", new String[] {getParameter("new_nick")}, null);
   
    // validate inputs
    ArrayList  errors = new ArrayList();
    String    botname = null;
    if (hasSubmission("perform_change"))
    {
      botname = getParameter("bot_to_change");
      if (isParameterEmpty("new_nick"))
      {
        errors.add(new ValidationError.MANDATORY("nick"));
      }
    }
    else
    {
      botname = getInput("botname");
    }
    Bot bot = Home.validateBotName(errors, botname);
   
    // act according to the actions that were performed
    if (errors.size() > 0)
    {
      if (botname != null)
      {
        t.setValue("botname", encodeHtml(botname));
      }
      validation_builder.generateValidationErrors(t, errors, null, null);
      validation_builder.generateErrorMarkings(t, errors, null, null);
    }
    else
    {
      if (hasSubmission("perform_change"))
      {
        String new_nick = getParameter("new_nick");
       
        t.setValue("botname", encodeHtml(bot.getName()));
        t.setValue("nick", encodeHtml(new_nick));

        try
        {
          bot.addBotListener(this);
          bot.changeNick(new_nick);
          synchronized (this)
          {
            if (null == bot.getConnectedNick() ||
              !bot.getConnectedNick().equals(new_nick))
            {
              try
              {
                this.wait();
              }
              catch (InterruptedException e)
              {
                // do nothing
              }
            }
          }
          bot.removeBotListener(this);
         
          if (bot.getConnectedNick().equals(new_nick))
          {
            exit("nick_changed");
          }
          validation_builder.setFallbackErrorArea(t, t.getBlock("ERROR_CHANGING_NICK"));
        }
        catch (CoreException e)
        {
          validation_builder.setFallbackErrorArea(t, t.getBlock("ERROR_CHANGING_NICK"));
        }
      }
    }
     
    setSubmissionForm(t, "perform_change", new String[] {"bot_to_change", botname});
View Full Code Here


 
      exit("search");
    }
    else
    {
      ValidationBuilder   validationBuilder = mTemplate.getBeanHandler().getFormBuilder().getValidationBuilder();
      List         validationErrors = new ArrayList();
     
      validationErrors.add(new ValidationError.INVALID("q"));
     
      validationBuilder.generateErrorMarkings(mTemplate, validationErrors, null, null);
      validationBuilder.generateValidationErrors(mTemplate, validationErrors, null, null);
    }
   
    processElement();
  }
View Full Code Here

TOP

Related Classes of com.uwyn.rife.site.ValidationBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.