AgileApps Support Wiki Pre Release

DirectoryPopupController.java

From AgileApps Support Wiki
package com.platform.demo.samples;

import com.platform.api.*;
import java.util.HashMap;

public class DirectoryPopupController implements Controller
{
  // Controller execute method
  public ControllerResponse execute(HashMap params) throws Exception
  {
    String action = (String)params.get("action");
    if(action == null || action.equals("")) action = "search";

    ControllerResponse cr = new ControllerResponse();
    DirectoryPopup directory= new DirectoryPopup();

    Result result = null;
    boolean delete = false;
    if(action.equals("search"))
    {
      result = directory.search(params);
      cr.setTargetPage("DirectoryPopup.jsp");
    }

    if(result == null)
    {
       // Do nothing
    }
    else if(result.getCode() < 0)
    {
      cr.setMessage(result.getMessage());
    }
    else
    {
      params.put("opResult", result);
      if(!delete)
          cr.setMessage(result.getMessage());
    }

    cr.setData(params);
    return cr;
  }
}