Exemplo n.º 1
0
  public void main(IWContext iwc) throws Exception {
    ELUtil.getInstance().autowire(this);

    String val = iwc.getParameter("submitBtn");
    if (!StringUtil.isEmpty(val)) {
      dao.createDish(
          iwc.getParameter("dishName"),
          iwc.getParameter("dishDescription"),
          iwc.getParameter("dishPrice"));
    }

    Layer container = new Layer(); // 	<div>
    add(container);

    IWResourceBundle iwrb = getResourceBundle(iwc);

    Form form = new Form();
    container.add(form);

    createField(form, "Dish", "dish_name", new TextInput("dishName"), iwrb);
    createField(form, "Description", "description", new TextArea("dishDescription"), iwrb);
    createField(form, "Price", "price", new TextInput("dishPrice"), iwrb);

    SubmitButton submitBtn =
        new SubmitButton("submitBtn", iwrb.getLocalizedString("submit", "Submit"));
    form.add(submitBtn);
  }
    public void main(IWContext iwc) throws Exception {

      Form myForm = new Form();
      myForm.maintainParameter(_PARAMETER_GROUP_ID);

      int groupId = -1;
      try {
        groupId = Integer.parseInt(iwc.getParameter(_PARAMETER_GROUP_ID));
      } catch (Exception ex) {
        // do Nothing
      }

      if (iwc.getParameter("commit") != null) {

        // Save

        // System.out.println("----------------------------");
        // System.out.println("users: "+iwc.getParameterValues(_USERS_RELATED));

        UserGroupBusiness.updateUsersInGroup(groupId, iwc.getParameterValues(_USERS_RELATED));

        this.setParentToReload();
        this.close();

      } else {
        UserList uList = new UserList(_USERS_RELATED);

        List lDirect =
            com.idega.core.user.business.UserGroupBusiness.getUsersContainedDirectlyRelated(
                groupId);
        Set direct = new HashSet();
        if (lDirect != null) {
          Iterator iter = lDirect.iterator();
          while (iter.hasNext()) {
            User item = (User) iter.next();
            direct.add(Integer.toString(item.getGroupID()));
          }
        }
        uList.setDirectlyRelatedUserIds(direct);

        List lNotDirect =
            com.idega.core.user.business.UserGroupBusiness.getUsersContainedNotDirectlyRelated(
                groupId);
        Set notDirect = new HashSet();
        if (lNotDirect != null) {
          Iterator iter2 = lNotDirect.iterator();
          while (iter2.hasNext()) {
            User item = (User) iter2.next();
            notDirect.add(Integer.toString(item.getGroupID()));
          }
        }
        uList.setRelatedUserIdsNotDirectly(notDirect);

        myForm.add(uList);

        myForm.add(new SubmitButton("commit", "    OK   "));
        myForm.add(new CloseButton("  Cancel  "));
        this.add(myForm);
      }
    }
Exemplo n.º 3
0
  public boolean initializeEvent(IWContext iwc) {
    this._appId = iwc.getParameter(IW_FRAMESET_PAGE_PARAMETER);
    this._src = iwc.getParameter(PRM_IW_BROWSE_EVENT_SOURCE);
    this._ctrlTarget = iwc.getParameter(IW_FRAME_NAME_PARAMETER);

    return (this._appId != null && this._src != null && this._ctrlTarget != null);
  }
  public Table getNavigationTable(IWContext iwc) {

    int usersSize = 0;
    if (this.users != null) {
      usersSize = this.users.size();
    }

    int maxPage = (int) Math.ceil(usersSize / this.USERS_PER_PAGE);

    Table navigationTable = new Table(3, 1);
    navigationTable.setCellpadding(2);
    navigationTable.setCellspacing(0);
    navigationTable.setWidth(Table.HUNDRED_PERCENT);
    navigationTable.setBorder(0);
    navigationTable.setWidth(1, "33%");
    navigationTable.setWidth(2, "33%");
    navigationTable.setWidth(3, "33%");
    navigationTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_CENTER);
    navigationTable.setAlignment(3, 1, Table.HORIZONTAL_ALIGN_RIGHT);

    Text prev = getSmallText(localize("previous", "Previous"));
    Text next = getSmallText(localize("next", "Next"));
    Text info =
        getSmallText(
            localize("page", "Page")
                + " "
                + (this.currentPage + 1)
                + " "
                + localize("of", "of")
                + " "
                + (maxPage + 1));
    if (this.currentPage > 0) {
      Link lPrev = getLink(getSmallText(localize("previous", "Previous")), iwc);
      lPrev.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage - 1));
      lPrev.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lPrev.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lPrev, 1, 1);
    } else {
      navigationTable.add(prev, 1, 1);
    }
    navigationTable.add(info, 2, 1);

    if (this.currentPage < maxPage) {
      Link lNext = getLink(getSmallText(localize("next", "Next")), iwc);
      lNext.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage + 1));
      lNext.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lNext.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lNext, 3, 1);
    } else {
      navigationTable.add(next, 3, 1);
    }
    return navigationTable;
  }
  // œr private ’ protected
  protected void init(IWContext iwc) {
    this.form = new Form();
    this.searchString = iwc.getParameter(this.PARAMETER_SEARCH);
    this.iwrb =
        iwc.getIWMainApplication()
            .getBundle(BuilderConstants.STANDARD_IW_BUNDLE_IDENTIFIER)
            .getResourceBundle(iwc);
    this.showAll = iwc.isParameterSet(this.PARAMETER_VIEW_ALL);

    if (iwc.isParameterSet(this.PARAMETER_CURRENT_PAGE)) {
      this.currentPage = Integer.parseInt(iwc.getParameter(this.PARAMETER_CURRENT_PAGE));
    }
    // int start = currentPage * USERS_PER_PAGE;

    try {
      String useUserPks =
          (String) iwc.getSessionAttribute(USING_AVAILABLE_USER_PKS_SESSION_PARAMETER);
      if (useUserPks != null) {
        this.usingUserPks = true;
      }
      Collection availableUserPks =
          (Collection) iwc.getSessionAttribute(AVAILABLE_USER_PKS_SESSION_PARAMETER);
      String[] userIds = null;
      if (this.usingUserPks && availableUserPks != null) {
        userIds = new String[availableUserPks.size()];
        Iterator iter = availableUserPks.iterator();
        int counter = 0;
        while (iter.hasNext()) {
          Object i = iter.next();
          userIds[counter++] = i.toString();
        }
      }
      if (this.usingUserPks && this.searchString == null) {
        this.showAll = true;
      }

      UserHome uHome = (UserHome) IDOLookup.getHome(User.class);
      if (this.showAll) {
        if (this.usingUserPks && userIds != null) {
          this.users = uHome.findUsers(userIds);
        } else {
          this.users = uHome.findAllUsersOrderedByFirstName();
        }
      } else if (this.searchString != null) {
        this.users = uHome.findUsersBySearchCondition(this.searchString, userIds, false);
      }
    } catch (Exception e) {
      e.printStackTrace(System.err);
    }
  }
  protected void init(IWContext iwc) {
    this.form = new Form();
    this.form.maintainParameter(SchoolUserChooser.PARAMETER_SCHOOL_ID);

    this.searchString = iwc.getParameter(this.PARAMETER_SEARCH);
    this.iwrb =
        iwc.getIWMainApplication()
            .getBundle(BuilderConstants.STANDARD_IW_BUNDLE_IDENTIFIER)
            .getResourceBundle(iwc);
    this.showAll = iwc.isParameterSet(this.PARAMETER_VIEW_ALL);
    if (iwc.isParameterSet(this.PARAMETER_CURRENT_PAGE)) {
      this.currentPage = Integer.parseInt(iwc.getParameter(this.PARAMETER_CURRENT_PAGE));
    }
    try {
      SchoolUserBusiness biz = getSchoolUserBusiness(iwc);
      int[] userTypes = {
        SchoolUserBusinessBean.USER_TYPE_HEADMASTER,
        SchoolUserBusinessBean.USER_TYPE_ASSISTANT_HEADMASTER,
        SchoolUserBusinessBean.USER_TYPE_IB_COORDINATOR,
        SchoolUserBusinessBean.USER_TYPE_STUDY_AND_WORK_COUNCEL,
        SchoolUserBusinessBean.USER_TYPE_TEACHER,
        SchoolUserBusinessBean.USER_TYPE_WEB_ADMIN,
        SchoolUserBusinessBean.USER_TYPE_SCHOOL_MASTER,
        SchoolUserBusinessBean.USER_TYPE_CONTACT_PERSON,
        SchoolUserBusinessBean.USER_TYPE_EXPEDITION,
        SchoolUserBusinessBean.USER_TYPE_PROJECT_MANAGER
      };

      School prov = getProvider(iwc);

      if (prov == null) {
        SchoolUserHome userHome;
        userHome = (SchoolUserHome) IDOLookup.getHome(SchoolUser.class);
        Collection schoolUsers = userHome.findByTypes(userTypes);

        this.users = new Vector();
        Iterator iter = schoolUsers.iterator();
        while (iter.hasNext()) {
          SchoolUser sUser = (SchoolUser) iter.next();
          this.users.add(sUser.getUser());
        }
      } else {
        this.users = biz.getUsers(prov, userTypes);
      }
    } catch (FinderException ex) {
      ex.printStackTrace();
    } catch (RemoteException ex) {
      ex.printStackTrace();
    }
  }
 public void main(IWContext iwc) throws Exception {
   super.main(iwc);
   init(iwc);
   setTitle(this.iwrb.getLocalizedString(WINDOW_NAME, "Update League Template Window"));
   addTitle(
       this.iwrb.getLocalizedString(WINDOW_NAME, "Update League Template Window"),
       TITLE_STYLECLASS);
   if (this.group != null) {
     if (this.group.getGroupType().equals(IWMemberConstants.GROUP_TYPE_CLUB_DIVISION_TEMPLATE)
         || this.group.getGroupType().equals(IWMemberConstants.GROUP_TYPE_LEAGUE)) {
       String action = iwc.getParameter(ACTION);
       if (action == null) {
         addForm(iwc);
       } else if (action.equals(ACTION_CANCEL)) {
         close();
       } else if (action.equals(ACTION_UPDATE)) {
         addInfo(iwc);
         updateChildren(iwc);
       }
     } else {
       add(
           this.iwrb.getLocalizedString(
               WRONG_GROUP_TYPE,
               "Please select either a league, or a division template under a league."));
     }
   } else {
     add(
         this.iwrb.getLocalizedString(
             WRONG_GROUP_TYPE,
             "Please select either a league, or a division template under a league."));
   }
 }
  public void main(IWContext iwc) throws Exception {
    try {
      if (iwc.isParameterSet(PARAMETER_RACE)) {
        race =
            ConverterUtility.getInstance()
                .convertGroupToRace(new Integer(iwc.getParameter(PARAMETER_RACE)));
      }
    } catch (Exception e) {
    }

    Layer layer = new Layer(Layer.DIV);
    layer.setStyleClass("raceElement");
    layer.setID("raceParticipants");

    Layer headerLayer = new Layer(Layer.DIV);
    headerLayer.setStyleClass("raceParticipantsHeader");
    layer.add(headerLayer);

    Layer headingLayer = new Layer(Layer.DIV);
    headingLayer.setStyleClass("raceParticipantHeading");
    headingLayer.add(new Text(getHeading()));
    headerLayer.add(headingLayer);

    layer.add(getRaceParticipantList(iwc));

    add(layer);
  }
  private User getPupilFromParam(IWContext iwc) throws RemoteException {
    User child = null;
    // Parameter name returning chosen User from SearchUserModule
    this.uniqueUserSearchParam = SearchUserModule.getUniqueUserParameterName(UNIQUE_SUFFIX);

    if (iwc.isParameterSet(PARAM_PUPIL_ID)) {
      String idStr = iwc.getParameter(PARAM_PUPIL_ID);
      int childID = Integer.parseInt(idStr);
      child = getUserBusiness(iwc).getUser(childID);
    } else if (iwc.isParameterSet(this.uniqueUserSearchParam)) {
      int childID = Integer.parseInt(iwc.getParameter(this.uniqueUserSearchParam));
      child = getUserBusiness(iwc).getUser(childID);
    }

    return child;
  }
Exemplo n.º 10
0
  /** @see com.idega.presentation.ui.InterfaceObject#handleKeepStatus(IWContext) */
  public void handleKeepStatus(IWContext iwc) {
    initilizeValues();
    String name = iwc.getParameter(getName());

    String nameDay = null;
    String nameMonth = null;
    String nameYear = null;
    if (name != null && !"".equals(name)) {
      nameDay = name.substring(8, 10);
      nameMonth = name.substring(5, 7);
      nameYear = name.substring(0, 4);
    }

    if (this.theDay != null && nameDay != null) {
      this.theDay.setSelectedElement(nameDay);
    }

    if (nameMonth != null) {
      this.theMonth.setSelectedElement(nameMonth);
    }

    if (this.theYear != null && nameYear != null) {
      this.theYear.setSelectedElement(nameYear);
    }

    if (name != null) {
      this.theWholeDate.setValue(name);
    }
  }
Exemplo n.º 11
0
  private void init(IWContext iwc) {
    this.bundle = getBundle(iwc);
    this.iwrb = this.bundle.getResourceBundle(iwc);
    this.iwc = iwc;
    setAutoCreate(false);
    if (iwc.isParameterSet(this.prmClrCache)) {
      clearCache(iwc);
    }
    this._currentLocale = iwc.getCurrentLocale();
    this._currentLocaleId = ICLocaleBusiness.getLocaleId(this._currentLocale);
    this._hasEditPermission = this.hasEditPermission();
    if (iwc.isInPreviewMode()) {
      this._hasEditPermission = false;
    }
    IWBundle coreBundle = iwc.getIWMainApplication().getCoreBundle();
    this.iCreate = coreBundle.getImage("shared/create.gif");
    this.iDelete = coreBundle.getImage("shared/delete.gif");
    this.iEdit = coreBundle.getImage("shared/edit.gif");
    this.iDetach = coreBundle.getImage("shared/detach.gif");
    try {
      this.layout = (AbstractProductCatalogLayout) this._layoutClass.newInstance();
    } catch (IllegalAccessException iae) {
      iae.printStackTrace(System.err);
    } catch (InstantiationException ie) {
      ie.printStackTrace(System.err);
    }
    try {
      String sCurrentPage = iwc.getParameter(ProductCatalog._VIEW_PAGE);
      String sOrderBy = iwc.getParameter(ProductCatalog._ORDER_BY);
      if (sCurrentPage != null) {
        this.currentPage = Integer.parseInt(sCurrentPage);
      }
      if (sOrderBy != null) {
        this.orderBy = Integer.parseInt(sOrderBy);
      }
    } catch (NumberFormatException n) {
    }

    this.expandedCategories = new Vector();
    String selCat = iwc.getParameter(CATEGORY_ID);

    if (selCat != null) {
      this._selectedCategoryID = Integer.parseInt(selCat);
      addCategoryAsExpanded(selCat);
    }
  }
    private void LineUpElements(IWContext iwc) {

      Form form = new Form();

      Table frameTable = new Table(3, 3);
      frameTable.setWidth("100%");
      frameTable.setHeight("100%");
      // frameTable.setBorder(1);

      SelectionDoubleBox sdb =
          new SelectionDoubleBox(GroupGroupSetter.FIELDNAME_SELECTION_DOUBLE_BOX, "Not in", "In");

      SelectionBox left = sdb.getLeftBox();
      left.setHeight(8);
      left.selectAllOnSubmit();

      SelectionBox right = sdb.getRightBox();
      right.setHeight(8);
      right.selectAllOnSubmit();

      String stringGroupId = iwc.getParameter(GroupGroupSetter.PARAMETER_GROUP_ID);
      int groupId = Integer.parseInt(stringGroupId);
      form.addParameter(GroupGroupSetter.PARAMETER_GROUP_ID, stringGroupId);

      List directGroups = UserGroupBusiness.getGroupsContainingDirectlyRelated(groupId);

      Iterator iter = null;
      if (directGroups != null) {
        iter = directGroups.iterator();
        while (iter.hasNext()) {
          Object item = iter.next();
          right.addElement(
              Integer.toString(((GenericGroup) item).getID()), ((GenericGroup) item).getName());
        }
      }
      List notDirectGroups = UserGroupBusiness.getRegisteredGroupsNotDirectlyRelated(groupId, iwc);
      if (notDirectGroups != null) {
        iter = notDirectGroups.iterator();
        while (iter.hasNext()) {
          Object item = iter.next();
          left.addElement(
              Integer.toString(((GenericGroup) item).getID()), ((GenericGroup) item).getName());
        }
      }

      // left.addSeparator();
      // right.addSeparator();

      frameTable.setAlignment(2, 2, "center");
      frameTable.add("GroupId: " + groupId, 2, 1);
      frameTable.add(sdb, 2, 2);
      frameTable.add(new SubmitButton("  Save  ", "save", "true"), 2, 3);
      frameTable.add(new CloseButton("  Cancel  "), 2, 3);
      frameTable.setAlignment(2, 3, "right");
      form.add(frameTable);
      this.add(form);
    }
Exemplo n.º 13
0
 Product getSelectedProduct(IWContext iwc) {
   String sProductId = iwc.getParameter(ProductBusinessBean.PRODUCT_ID);
   if (sProductId != null) {
     try {
       Product product = getProductBusiness().getProduct(Integer.parseInt(sProductId));
       return product;
     } catch (Exception e) {
       e.printStackTrace(System.err);
     }
   }
   return null;
 }
Exemplo n.º 14
0
 protected String getCacheState(IWContext iwc, String cacheStatePrefix) {
   Product prod = getSelectedProduct(iwc);
   //    System.out.println("[ProductCatalog] gettingCacheState");
   String returnString = cacheStatePrefix + getICObjectInstanceID();
   if (iwc.isParameterSet(CATEGORY_ID)) {
     returnString = returnString + "_" + iwc.getParameter(CATEGORY_ID);
   }
   if (prod != null) {
     returnString = returnString + "_" + prod.getID();
   }
   return returnString;
 }
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    IWContext iwc = new IWContext(req, resp, req.getSession().getServletContext());
    if (iwc.isParameterSet(PARAMETER_WELL_PK)) {
      WebApplicationContext springContext =
          WebApplicationContextUtils.getWebApplicationContext(iwc.getServletContext());
      HephaestusService service = (HephaestusService) springContext.getBean("hephaestusService");

      Well well = service.getWell(Long.parseLong(iwc.getParameter(PARAMETER_WELL_PK)));
      List<LogHeader> headers = new ArrayList<LogHeader>();
      if (iwc.isParameterSet(PARAMETER_LOG_PK)) {
        String[] logPKs = iwc.getParameterValues(PARAMETER_LOG_PK);
        for (String pk : logPKs) {
          headers.add(service.getLogHeader(Long.parseLong(pk)));
        }
      }

      String measurementType = iwc.getParameter(PARAMETER_MEASUREMENT_TYPE);

      String imageURL = HephaestusUtil.getImageForWell(well, headers, measurementType);
      if (imageURL == null || imageURL.isEmpty()) {
        resp.setStatus(404);
        return;
      }

      resp.setStatus(200);
      resp.setContentType("image/png");

      File f = new File(imageURL);
      BufferedImage bi = ImageIO.read(f);
      OutputStream out = resp.getOutputStream();
      ImageIO.write(bi, "png", out);
      out.close();

    } else {
      resp.setStatus(404);
    }
  }
 public String getEnabledCategories(IWContext iwc) {
   StringBuffer categories = new StringBuffer(CategoryBean.CATEGORY_DELIMETER);
   CategoryBean categoryBean = CategoryBean.getInstance();
   String selectedCategory = null;
   for (ContentCategory category : categoryBean.getCategories()) {
     selectedCategory = iwc.getParameter(getCategoryKey(category));
     if (!StringUtil.isEmpty(selectedCategory)
         && selectedCategory.equals(Boolean.TRUE.toString())) {
       categories.append(category.getId()).append(CategoryBean.CATEGORY_DELIMETER);
     }
   }
   return categories.toString();
 }
 private void parseAction(IWContext iwc)
     throws NumberFormatException, IDOStoreException, IOException, RemoteException,
         FinderException {
   if (iwc.isParameterSet(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID)) {
     this.layoutFolderId = iwc.getParameter(ReportQueryBuilder.PARAM_LAYOUT_FOLDER_ID);
   } else {
     return;
   }
   if (iwc.isParameterSet(KEY_QUERY_UPLOAD_IS_SUBMITTED)) {
     Object queryToBeReplacedId = iwc.getParameter(KEY_CHOSEN_QUERY_FOR_REPLACING);
     if (VALUE_DO_NOT_REPLACE_A_QUERY.equals(queryToBeReplacedId)) {
       queryToBeReplacedId = null;
     } else {
       queryToBeReplacedId = new Integer((String) queryToBeReplacedId);
     }
     UploadFile uploadFile = iwc.getUploadedFile();
     ICFile icFile = MediaBusiness.saveMediaToDBUploadFolder(uploadFile, iwc);
     String name = iwc.getParameter(KEY_QUERY_NAME);
     String permission = iwc.getParameter(KEY_PERMISSION);
     boolean isPrivate = PRIVATE.equals(permission);
     QueryService queryService =
         (QueryService) IBOLookup.getServiceInstance(iwc, QueryService.class);
     UserQuery userQuery =
         queryService.storeQuery(name, icFile, isPrivate, queryToBeReplacedId, iwc);
     this.userQueryId = ((Integer) userQuery.getPrimaryKey()).intValue();
   } else if (iwc.isParameterSet(KEY_QUERY_DOWNLOAD_IS_SUBMITTED)) {
     Object queryToBeDownloadedId = iwc.getParameter(KEY_CHOSEN_QUERY_FOR_DOWNLOADING);
     if (!VALUE_DO_NOT_REPLACE_A_QUERY.equals(queryToBeDownloadedId)) {
       Integer queryToBeDownloaded = new Integer((String) queryToBeDownloadedId);
       UserQueryHome userQueryHome = (UserQueryHome) IDOLookup.getHome(UserQuery.class);
       UserQuery userQuery = userQueryHome.findByPrimaryKey(queryToBeDownloaded);
       ICFile realQuery = userQuery.getSource();
       FileBusiness fileBusiness =
           (FileBusiness) IBOLookup.getServiceInstance(iwc, FileBusiness.class);
       this.downloadUrl = fileBusiness.getURLForOfferingDownload(realQuery, iwc);
     }
   }
 }
  public void main(IWContext iwc) throws Exception {
    // iwrb = getResourceBundle(iwc);
    this.form = new Form();
    this.form.setName(SEARCH_FORM_NAME);

    // Parameter name returning chosen User from SearchUserModule
    this.uniqueUserSearchParam = SearchUserModule.getUniqueUserParameterName(UNIQUE_SUFFIX);
    this.form.maintainAllParameters();

    if (iwc.isParameterSet(PARAM_REMOVE_PLACEMENT)
        && !("-1".equals(iwc.getParameter(PARAM_REMOVE_PLACEMENT)))) {
      // A remove placement button is pressed
      String plcIdStr = null;
      try {
        plcIdStr = iwc.getParameter(PARAM_REMOVE_PLACEMENT);
        Integer plcPK = new Integer(plcIdStr);
        getCentralPlacementBusiness(iwc).removeSchoolClassMember(plcPK);
      } catch (Exception e) {
        logWarning("Error erasing SchooClassMember with PK: " + plcIdStr);
        log(e);
      }
    }

    this.pupil = getPupilFromParam(iwc);

    this.form.add(getMainTable());
    setMainTableContent(getSearchTable(iwc));
    setMainTableContent(getPupilTable(iwc, this.pupil));
    setMainTableContent(getPlacementTable(iwc));

    // Add empty bottom that fills the bottom window space
    setMainTableContent(this.transGIF);
    this.mainTable.setHeight(1, this.mainTableRow - 1, Table.HUNDRED_PERCENT);

    add(this.form);
  }
Exemplo n.º 19
0
 private boolean isAllowAction(IWContext iwc) {
   Object allowValue = iwc.getRequest().getAttribute(OpenIDConstants.PARAMETER_ALLOWED);
   if (allowValue != null) {
     return true;
   } else {
     String paramValue = iwc.getParameter(OpenIDConstants.PARAMETER_ALLOWED);
     String sessionValue = (String) iwc.getSessionAttribute(OpenIDConstants.PARAMETER_ALLOWED);
     iwc.removeSessionAttribute(OpenIDConstants.PARAMETER_ALLOWED);
     if (paramValue != null && paramValue.equals(sessionValue)) {
       iwc.getRequest().setAttribute(OpenIDConstants.PARAMETER_ALLOWED, "true");
       return true;
     }
   }
   return false;
 }
 private void init(IWContext iwc) {
   String sGroupId = iwc.getParameter(PARAMETER_GROUP_ID);
   if (sGroupId != null) {
     try {
       GroupHome gHome = (GroupHome) IDOLookup.getHome(Group.class);
       this.group = gHome.findByPrimaryKey(new Integer(sGroupId));
     } catch (IDOLookupException e) {
       e.printStackTrace(System.err);
     } catch (NumberFormatException e) {
       e.printStackTrace(System.err);
     } catch (FinderException e) {
       e.printStackTrace(System.err);
     }
   }
   this.iwrb = getResourceBundle(iwc);
 }
 public School getProvider(IWContext iwc) {
   School _provider = null;
   try {
     if (iwc.isParameterSet(SchoolUserChooser.PARAMETER_SCHOOL_ID)) {
       _provider =
           getSchoolBusiness(iwc)
               .getSchool(iwc.getParameter(SchoolUserChooser.PARAMETER_SCHOOL_ID));
       if (iwc.getSessionAttribute(SchoolUserChooser.PARAMETER_SCHOOL_ID) == null) {
         iwc.setSessionAttribute(SchoolUserChooser.PARAMETER_SCHOOL_ID, _provider);
       }
     } else {
       _provider = (School) iwc.getSessionAttribute(SchoolUserChooser.PARAMETER_SCHOOL_ID);
     }
   } catch (RemoteException ex) {
     ex.printStackTrace();
   }
   return _provider;
 }
 public void main(IWContext iwc) throws Exception {
   // debugParameters(iwc);
   LoginEditor BE = new LoginEditor();
   if (iwc.isParameterSet(PARAM_MESSAGE)) {
     BE.setMessage(iwc.getParameter(PARAM_MESSAGE));
   }
   if (iwc.isParameterSet(PARAM_CHANGE)) {
     BE.setChangeLoginNextTime(true);
   }
   Table T = new Table(1, 1);
   T.setAlignment(1, 1, "center");
   T.setStyleClass(MAIN_STYLECLASS);
   T.add(BE, 1, 1);
   add(T, iwc);
   addTitle(
       getResourceBundle(iwc).getLocalizedString("login_editor", "Login Editor"),
       TITLE_STYLECLASS);
   // setTitle("Login Editor");
   // addTitle("Login Editor");
 }
Exemplo n.º 23
0
  /**
   * @see
   *     com.idega.presentation.ui.AbstractChooserWindow#displaySelection(com.idega.presentation.IWContext)
   */
  public void displaySelection(IWContext iwc) {
    String uId = iwc.getParameter(this.PARAMETER_USER_ID);
    if (uId != null) {
      try {
        User user = getUserHome().findByPrimaryKey(new Integer(uId));
        Page page = getParentPage();
        page.setOnLoad(SELECT_FUNCTION_NAME + "('" + user.getName() + "','" + uId + "')");
      } catch (RemoteException e) {
      } catch (FinderException e) {
      }
    } else {

      init(iwc);

      addTitle(this.iwrb.getLocalizedString("select_a_user", "Select a user"), TITLE_STYLECLASS);

      this.form.maintainParameter(SCRIPT_PREFIX_PARAMETER);
      this.form.maintainParameter(SCRIPT_SUFFIX_PARAMETER);
      this.form.maintainParameter(DISPLAYSTRING_PARAMETER_NAME);
      this.form.maintainParameter(VALUE_PARAMETER_NAME);

      Table mainTable = new Table(1, 4);
      mainTable.setStyleClass(this.mainTableStyle);
      mainTable.setWidth(Table.HUNDRED_PERCENT);
      mainTable.setBorder(0);

      mainTable.add(getHeaderTable(iwc), 1, 1);
      mainTable.add(getNavigationTable(iwc), 1, 3);
      try {
        mainTable.add(getListTable(iwc), 1, 4);
      } catch (RemoteException r) {
        throw new RuntimeException(r.getMessage());
      }
      this.form.add(mainTable);
      add(this.form, iwc);
    }
  }
 public RemoteScriptingResults getResults(IWContext iwc) {
   String sourceName = iwc.getParameter(RemoteScriptHandler.PARAMETER_SOURCE_PARAMETER_NAME);
   String sourceID = iwc.getParameter(sourceName);
   return handleShirtSizeUpdate(iwc, sourceName, sourceID);
 }
  @Override
  public void present(IWContext iwc) throws Exception {
    this.iwrb = getResourceBundle(iwc);
    this.iwb = getBundle(iwc);

    List<ICLocale> locales = ICLocaleBusiness.listOfLocales();

    String action = iwc.getParameter(PARAMETER_ACTION);
    if (ACTION_CREATE.equals(action)) {
      getCategoryCreationForm(iwc, null, locales);
    } else if (ACTION_EDIT.equals(action)) {
      ApplicationCategory category =
          getApplicationBusiness(iwc)
              .getApplicationCategoryHome()
              .findByPrimaryKey(Integer.parseInt(iwc.getParameter("id")));
      getCategoryCreationForm(iwc, category, locales);
    } else if (ACTION_SAVE.equals(action)) {
      String id = iwc.getParameter("id");
      String name = iwc.getParameter("name");
      String desc = iwc.getParameter("desc");
      String priority = iwc.getParameter("priority");

      if (name != null && !name.trim().equals("")) {
        ApplicationCategory cat = null;
        if (id != null) {
          try {
            cat =
                getApplicationBusiness(iwc)
                    .getApplicationCategoryHome()
                    .findByPrimaryKey(new Integer(iwc.getParameter("id")));
          } catch (FinderException f) {
            f.printStackTrace();
          }
        } else {
          cat = getApplicationBusiness(iwc).getApplicationCategoryHome().create();
        }

        cat.setName(name);
        cat.setDescription(desc);
        if (priority != null && !priority.equals("")) {
          cat.setPriority(new Integer(priority));
        }
        cat.store();

        for (Iterator<ICLocale> it = locales.iterator(); it.hasNext(); ) {
          ICLocale locale = it.next();
          String locName = iwc.getParameter(locale.getName() + "_locale");

          if (locName != null && !locName.equals("")) {
            LocalizedText locText = cat.getLocalizedText(locale.getLocaleID());
            boolean newText = false;
            if (locText == null) {
              locText = getLocalizedTextHome().create();
              newText = true;
            }

            locText.setLocaleId(locale.getLocaleID());
            locText.setBody(locName);

            locText.store();

            if (newText) {
              cat.addLocalizedName(locText);
            }
          }
        }

        IWCacheManager.getInstance(iwc.getIWMainApplication())
            .invalidateCache(ApplicationCategoryViewer.CACHE_KEY);
        IWCacheManager.getInstance(iwc.getIWMainApplication())
            .invalidateCache(ApplicationFavorites.CACHE_KEY);
      }
      listExisting(iwc);
    } else if (ACTION_CATEGORY_UP.equals(action)) {
      String id = iwc.getParameter("id");

      ApplicationCategory cat = null;
      if (id != null) {
        try {
          cat =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPrimaryKey(new Integer(id));
        } catch (FinderException f) {
          f.printStackTrace();
        }
      }
      Integer priority = cat.getPriority();
      ApplicationCategory upperCat = null;
      if (priority != null) {
        try {
          upperCat =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPriority(priority.intValue() - 1);
          upperCat.setPriority(-1);
          upperCat.store();
        } catch (FinderException f) {
          f.printStackTrace();
        }
        cat.setPriority(priority.intValue() - 1);
      }

      cat.store();

      if (upperCat != null) {
        upperCat.setPriority(priority.intValue());
        upperCat.store();
      }

      clearApplicationCategoryViewerCache(iwc);

      listExisting(iwc);
    } else if (ACTION_CATEGORY_DOWN.equals(action)) {
      String id = iwc.getParameter("id");

      ApplicationCategory cat = null;
      if (id != null) {
        try {
          cat =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPrimaryKey(new Integer(id));
        } catch (FinderException f) {
          f.printStackTrace();
        }
      }
      Integer priority = cat.getPriority();
      ApplicationCategory lowerCat = null;
      if (priority != null) {
        try {
          lowerCat =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPriority(priority.intValue() + 1);
          lowerCat.setPriority(-1);
          lowerCat.store();
        } catch (FinderException f) {
          f.printStackTrace();
        }
        cat.setPriority(priority.intValue() + 1);
      }

      cat.store();

      if (lowerCat != null) {
        lowerCat.setPriority(priority.intValue());
        lowerCat.store();
      }

      clearApplicationCategoryViewerCache(iwc);

      listExisting(iwc);
    } else if (ACTION_APP_UP.equals(action)) {
      String appId = iwc.getParameter("app_id");
      String id = iwc.getParameter("id");

      Application app = null;
      ApplicationCategory category = null;
      if (appId != null) {
        try {
          app =
              getApplicationBusiness(iwc).getApplicationHome().findByPrimaryKey(new Integer(appId));
        } catch (FinderException f) {
          f.printStackTrace();
        }
      }
      Integer priority = app.getPriority();
      Application upperApp = null;
      if (priority != null) {
        try {
          category =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPrimaryKey(new Integer(id));

          upperApp =
              getApplicationBusiness(iwc)
                  .getApplicationHome()
                  .findByCategoryAndPriority(category, priority.intValue() - 1);
          upperApp.setPriority(-1);
          upperApp.store();
        } catch (FinderException f) {
          f.printStackTrace();
        }
        app.setPriority(priority.intValue() - 1);
      }

      app.store();

      if (upperApp != null) {
        upperApp.setPriority(priority.intValue());
        upperApp.store();
      }

      clearApplicationCategoryViewerCache(iwc);

      getCategoryCreationForm(iwc, category, locales);
    } else if (ACTION_APP_DOWN.equals(action)) {
      String appId = iwc.getParameter("app_id");
      String id = iwc.getParameter("id");

      Application app = null;
      ApplicationCategory category = null;
      if (appId != null) {
        try {
          app =
              getApplicationBusiness(iwc).getApplicationHome().findByPrimaryKey(new Integer(appId));
        } catch (FinderException f) {
          f.printStackTrace();
        }
      }
      Integer priority = app.getPriority();
      Application lowerApp = null;
      if (priority != null) {
        try {
          category =
              getApplicationBusiness(iwc)
                  .getApplicationCategoryHome()
                  .findByPrimaryKey(new Integer(id));

          lowerApp =
              getApplicationBusiness(iwc)
                  .getApplicationHome()
                  .findByCategoryAndPriority(category, priority.intValue() + 1);
          lowerApp.setPriority(-1);
          lowerApp.store();
        } catch (FinderException f) {
          f.printStackTrace();
        }
        app.setPriority(priority.intValue() + 1);
      }

      app.store();

      if (lowerApp != null) {
        lowerApp.setPriority(priority.intValue());
        lowerApp.store();
      }

      clearApplicationCategoryViewerCache(iwc);

      getCategoryCreationForm(iwc, category, locales);
    } else if (ACTION_DELETE.equals(action)) {
      try {
        ApplicationCategory cat =
            getApplicationBusiness(iwc)
                .getApplicationCategoryHome()
                .findByPrimaryKey(new Integer(iwc.getParameter("id")));
        cat.remove();
      } catch (FinderException f) {
        f.printStackTrace();
      }
      listExisting(iwc);
    } else if (ACTION_LIST.equals(action)) {
      listExisting(iwc);
    } else {
      listExisting(iwc);
    }
  }
    public void main(IWContext iwc) throws Exception {

      String save = iwc.getParameter("save");
      if (save != null) {
        String stringGroupId = iwc.getParameter(GroupGroupSetter.PARAMETER_GROUP_ID);
        int groupId = Integer.parseInt(stringGroupId);

        String[] related = iwc.getParameterValues(GroupGroupSetter.FIELDNAME_SELECTION_DOUBLE_BOX);

        GenericGroup group =
            ((com.idega.core.data.GenericGroupHome)
                    com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                .findByPrimaryKeyLegacy(groupId);
        List currentRelationShip = group.getParentGroups();

        if (related != null) {

          if (currentRelationShip != null) {
            for (int i = 0; i < related.length; i++) {
              int id = Integer.parseInt(related[i]);
              GenericGroup gr =
                  ((com.idega.core.data.GenericGroupHome)
                          com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                      .findByPrimaryKeyLegacy(id);
              if (!currentRelationShip.remove(gr)) {
                gr.addGroup(group);
              }
            }

            Iterator iter = currentRelationShip.iterator();
            while (iter.hasNext()) {
              Object item = iter.next();
              ((GenericGroup) item).removeGroup(group);
            }

          } else {
            for (int i = 0; i < related.length; i++) {
              ((com.idega.core.data.GenericGroupHome)
                      com.idega.data.IDOLookup.getHomeLegacy(GenericGroup.class))
                  .findByPrimaryKeyLegacy(Integer.parseInt(related[i]))
                  .addGroup(group);
            }
          }

        } else if (currentRelationShip != null) {
          Iterator iter = currentRelationShip.iterator();
          while (iter.hasNext()) {
            Object item = iter.next();
            ((GenericGroup) item).removeGroup(group);
          }
        }

        this.close();
        this.setParentToReload();
      } else {
        LineUpElements(iwc);
      }

      /*
            Enumeration enum = iwc.getParameterNames();
             System.err.println("--------------------------------------------------");
            if(enum != null){
              while (enum.hasMoreElements()) {
                Object item = enum.nextElement();
                if(item.equals("save")){
                  this.close();
                }
                String val[] = iwc.getParameterValues((String)item);
                System.err.print(item+" = ");
                if(val != null){
                  for (int i = 0; i < val.length; i++) {
                    System.err.print(val[i]+", ");
                  }
                }
                System.err.println();
              }
            }
      */
    }
  /** @see com.idega.presentation.PresentationObject#main(IWContext) */
  public void main(IWContext iwc) throws Exception {

    if (this.applicationGroup != null) {
      if (iwc.isParameterSet(USER_NAME_PARAM) && iwc.isParameterSet(PIN_PARAM)) {

        GroupApplicationBusiness biz = this.getGroupApplicationBusiness(iwc);

        String name = iwc.getParameter(USER_NAME_PARAM);
        String pin = iwc.getParameter(PIN_PARAM);
        String gender = iwc.getParameter(GENDER_PARAM);
        String email = iwc.getParameter(EMAIL_PARAM);
        String email2 = iwc.getParameter(EMAIL2_PARAM);
        String address = iwc.getParameter(ADDRESS_PARAM);
        String postal = iwc.getParameter(POSTAL_CODE_PARAM);
        String phone = iwc.getParameter(PHONE_PARAM);
        String phone2 = iwc.getParameter(PHONE2_PARAM);
        String comment = iwc.getParameter(COMMENT_PARAM);
        String adminComment = iwc.getParameter(ADMIN_COMMENT_PARAM);

        // KR hack
        if (adminComment == null) {
          String paymentType = iwc.getParameter("payment_type");
          String validMonth = iwc.getParameter("valid_month");
          String validYear = iwc.getParameter("valid_year");
          String nameOnCard = iwc.getParameter("name_on_credit_card");
          String pinOnCard = iwc.getParameter("credit_card_pin");
          String caretakerName = iwc.getParameter("caretaker_name");
          String caretakerPin = iwc.getParameter("caretaker_pin");
          String caretakerEmail = iwc.getParameter("caretaker_email");
          String cardNumber = iwc.getParameter("credit_card_number");
          boolean credit = false;

          if (paymentType != null) {
            if (paymentType.equals("C")) {
              credit = true;
            } else if (paymentType.equals("M")) {
              credit = false;
            }
          }

          if (credit && cardNumber != null) {
            adminComment =
                "Vill borga með kredit korti:\n"
                    + "Kortanúmer : "
                    + cardNumber
                    + "\n"
                    + "Gildir til : "
                    + validMonth
                    + "/"
                    + validYear
                    + "\n"
                    + "Korthafi : "
                    + nameOnCard
                    + "\n"
                    + "Kennitala korthafa : "
                    + pinOnCard
                    + "\n";
          } else if (!credit) {
            adminComment = "Vill staðgreiða\n";
          } else {
            adminComment = "Vill borga með korti en kortanúmerið vantar!\n";
          }

          if (caretakerName != null) {
            adminComment +=
                "Forráðamaður : "
                    + caretakerName
                    + "\n"
                    + "Kennitala forráðamanns : "
                    + caretakerPin
                    + "\n"
                    + "Netfang forráðamanns : "
                    + caretakerEmail
                    + "\n";
          }
        }

        String[] groups = iwc.getParameterValues(GROUPS_PARAM);
        if (groups == null) {
          System.err.println("GROUPS are Null!");
        }

        try {
          biz.createGroupApplication(
              this.applicationGroup,
              name,
              pin,
              gender,
              email,
              email2,
              address,
              postal,
              phone,
              phone2,
              comment,
              adminComment,
              groups);

        } catch (Exception e) {
          add("Error : Application creation failed!");
          e.printStackTrace();
        }

      } else {
        add("Error : No name and PIN!");
      }

    } else {
      add("The application group parameter has not been set");
    }
  }
  public void main(IWContext iwc) throws Exception {

    String providerId = iwc.getParameter(CCConstants.PROVIDER_ID);
    String appId = iwc.getParameter(CCConstants.APPID);
    School school = getChildCareBusiness(iwc).getSchoolBusiness().getSchool(providerId);

    ChildCarePrognosis prognosis =
        getChildCareBusiness(iwc).getPrognosis(Integer.parseInt(providerId));

    String prognosisText =
        prognosis == null
            ? this.style.localize("ccpqw_no_prognosis", "No prognosis available")
            : this.style.localize("ccpqw_three_months", "Three months:")
                + " "
                + prognosis.getThreeMonthsPrognosis()
                + "  "
                + this.style.localize("ccpqw_one_year", "One year:")
                + " "
                + prognosis.getOneYearPrognosis()
                + "  "
                + this.style.localize("ccpqw_updated_date", "Updated date:")
                + " "
                + prognosis.getUpdatedDate();

    Table appTbl = new Table();

    //		add(new Text("ProviderId: " + providerId));
    if (providerId != null) {
      Collection applications =
          getChildCareBusiness(iwc)
              .getOpenAndGrantedApplicationsByProvider(new Integer(providerId).intValue());

      Iterator i = applications.iterator();

      appTbl.add(this.HEADER_ORDER, 1, 1);
      appTbl.add(this.HEADER_QUEUE_DATE, 2, 1);
      appTbl.add(this.HEADER_FROM_DATE, 3, 1);
      appTbl.setRowColor(1, this.style.getHeaderColor());

      int row = 2;

      while (i.hasNext()) {
        ChildCareApplication app = (ChildCareApplication) i.next();

        Text
            queueOrder =
                this.style.getSmallText("" + getChildCareBusiness(iwc).getNumberInQueue(app)),
            queueDate = this.style.getSmallText(app.getQueueDate().toString()),
            fromDate = this.style.getSmallText(app.getFromDate().toString());
        //					currentAppId = style.getSmallText(""+app.getNodeID());   //debug only

        appTbl.add(queueOrder, 1, row);
        appTbl.add(queueDate, 2, row);
        appTbl.add(fromDate, 3, row);
        //				appTbl.add(currentAppId, 4, row);  //debug only

        if (app.getNodeID() == new Integer(appId).intValue()) {
          emphasizeText(queueOrder);
          emphasizeText(queueDate);
          emphasizeText(fromDate);
        }

        if (row % 2 == 0) {
          appTbl.setRowColor(row, this.style.getZebraColor1());
        } else {
          appTbl.setRowColor(row, this.style.getZebraColor2());
        }

        row++;
      }
    }

    Table layoutTbl = new Table();
    layoutTbl.add(this.PROVIDER, 1, 1);
    layoutTbl.add(this.style.getSmallText(school.getName()), 2, 1);

    layoutTbl.setRowHeight(2, "20px");

    layoutTbl.add(this.PROGNOSIS, 1, 3);
    layoutTbl.add(this.style.getSmallText(prognosisText), 2, 3);

    layoutTbl.setRowHeight(4, "20px");

    layoutTbl.add(appTbl, 1, 5);
    layoutTbl.mergeCells(1, 5, 2, 5);

    CloseButton closeBtn = (CloseButton) this.style.getStyledInterface(new CloseButton(this.CLOSE));
    layoutTbl.add(closeBtn, 2, 6);
    layoutTbl.setAlignment(2, 6, "right");

    add(layoutTbl);
  }
  private void updatePreferences(IWContext iwc) throws Exception {
    LoginTable loginTable =
        LoginDBHandler.getUserLogin(((Integer) user.getPrimaryKey()).intValue());
    String login = loginTable.getUserLogin();
    String currentPassword = iwc.getParameter(PARAMETER_CURRENT_PASSWORD);
    String newPassword1 = iwc.getParameter(PARAMETER_NEW_PASSWORD);
    String newPassword2 = iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED);

    String errorMessage = null;
    boolean updatePassword = false;

    try {

      // if authorized by bank id we allow the user change his preferences
      if (authorizedByBankID(iwc)) {

      } else if (requirePasswordVerification
          && !LoginDBHandler.verifyPassword(login, currentPassword)) {
        throw new Exception(localize(KEY_PASSWORD_INVALID, DEFAULT_PASSWORD_INVALID));
      }

      // Validate new password
      if (!newPassword1.equals("") || !newPassword2.equals("")) {
        if (newPassword1.equals("")) {
          throw new Exception(localize(KEY_PASSWORD_EMPTY, DEFAULT_PASSWORD_EMPTY));
        }
        if (newPassword2.equals("")) {
          throw new Exception(
              localize(KEY_PASSWORD_REPEATED_EMPTY, DEFAULT_PASSWORD_REPEATED_EMPTY));
        }
        if (!newPassword1.equals(newPassword2)) {
          throw new Exception(localize(KEY_PASSWORDS_NOT_SAME, DEFAULT_PASSWORDS_NOT_SAME));
        }
        if (newPassword1.length() < MIN_PASSWORD_LENGTH) {
          throw new Exception(localize(KEY_PASSWORD_TOO_SHORT, DEFAULT_PASSWORD_TOO_SHORT));
        }
        for (int i = 0; i < newPassword1.length(); i++) {
          char c = newPassword1.charAt(i);
          boolean isPasswordCharOK = false;
          if ((c >= 'a') && (c <= 'z')) {
            isPasswordCharOK = true;
          } else if ((c >= 'A') && (c <= 'Z')) {
            isPasswordCharOK = true;
          } else if ((c >= '0') && (c <= '9')) {
            isPasswordCharOK = true;
          } else if ((c == 'Œ') || (c == 'Š') || (c == 'š')) {
            isPasswordCharOK = true;
          } else if ((c == '?') || (c == '€') || (c == '…')) {
            isPasswordCharOK = true;
          }
          if (!isPasswordCharOK) {
            throw new Exception(localize(KEY_PASSWORD_CHAR_ILLEGAL, DEFAULT_PASSWORD_CHAR_ILLEGAL));
          }
        }
        updatePassword = true;
      }
    } catch (Exception e) {
      errorMessage = e.getMessage();
    }

    if (errorMessage != null) {
      add(getErrorText(" " + errorMessage));
    } else {
      // Ok to update preferences
      // UserBusiness ub = (UserBusiness) IBOLookup.getServiceInstance(iwc, UserBusiness.class);

      if (updatePassword) {
        LoginDBHandler.updateLogin(
            ((Integer) user.getPrimaryKey()).intValue(), login, newPassword1);
      }
    }
    drawForm(iwc);
    if (errorMessage == null) {
      add(new Break());
      add(getLocalizedText(KEY_PREFERENCES_SAVED, DEFAULT_PREFERENCES_SAVED));
    }
  }
  private void drawForm(IWContext iwc) {
    Form form = new Form();
    Table T = new Table();
    T.setCellpadding(2);
    T.setCellspacing(2);
    T.setBorder(0);
    form.add(T);

    Table table = new Table();
    //		table.setWidth(getWidth());
    table.setCellpadding(2);
    table.setCellspacing(2);
    table.setBorder(0);
    T.add(table, 1, 1);
    T.setWidth(2, 1, "20");

    T.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_BOTTOM);
    T.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_BOTTOM);

    int row = 1;

    String personalID =
        PersonalIDFormatter.format(
            user.getPersonalID(), iwc.getIWMainApplication().getSettings().getApplicationLocale());

    table.add(new Break(2), 1, row);
    table.add(getSmallHeader(localize(KEY_PID, DEFAULT_PID)), 1, row);

    if (user.getPersonalID() != null) {
      table.add(getSmallText(personalID), 2, row);
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_BOTTOM);
      table.setVerticalAlignment(2, row, Table.VERTICAL_ALIGN_BOTTOM);
    }
    row++;
    table.add(getSmallHeader(localize(KEY_LOGIN, DEFAULT_LOGIN)), 1, row);
    LoginTable loginTable =
        LoginDBHandler.getUserLogin(((Integer) user.getPrimaryKey()).intValue());
    if (loginTable != null) {
      table.add(new HiddenInput(PARAMETER_OLD_LOGIN, loginTable.getUserLogin()), 2, row);
      table.add(getSmallText(loginTable.getUserLogin()), 2, row);
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_BOTTOM);
      table.setVerticalAlignment(2, row, Table.VERTICAL_ALIGN_BOTTOM);
    }

    String valueCurrentPassword =
        iwc.getParameter(PARAMETER_CURRENT_PASSWORD) != null
            ? iwc.getParameter(PARAMETER_CURRENT_PASSWORD)
            : "";
    String valueNewPassword =
        iwc.getParameter(PARAMETER_NEW_PASSWORD) != null
            ? iwc.getParameter(PARAMETER_NEW_PASSWORD)
            : "";
    String valueNewPasswordRepeated =
        iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED) != null
            ? iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED)
            : "";

    // Text tLogin = getSmallHeader(localize(KEY_LOGIN, DEFAULT_LOGIN));
    Text tCurrentPassword =
        getSmallHeader(localize(KEY_CURRENT_PASSWORD, DEFAULT_CURRENT_PASSWORD));
    Text tNewPassword = getSmallHeader(localize(KEY_NEW_PASSWORD, DEFAULT_NEW_PASSWORD));
    Text tNewPasswordRepeated =
        getSmallHeader(localize(KEY_NEW_PASSWORD_REPEATED, DEFAULT_NEW_PASSWORD_REPEATED));

    PasswordInput tiCurrentPassword =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_CURRENT_PASSWORD));
    if (valueCurrentPassword != null) {
      tiCurrentPassword.setValue(valueCurrentPassword);
    }
    PasswordInput tiNewPassword =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_NEW_PASSWORD));
    if (valueNewPassword != null) {
      tiNewPassword.setValue(valueNewPassword);
    }
    PasswordInput tiNewPasswordRepeated =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_NEW_PASSWORD_REPEATED));
    if (valueNewPasswordRepeated != null) {
      tiNewPasswordRepeated.setValue(valueNewPasswordRepeated);
    }

    SubmitButton sbUpdate =
        (SubmitButton)
            getStyledInterface(
                new SubmitButton(
                    localize(KEY_UPDATE, DEFAULT_UPDATE), PARAMETER_FORM_SUBMIT, "true"));

    row++;
    table.setHeight(row, 12);

    if (requirePasswordVerification) {
      row++;
      table.add(tCurrentPassword, 1, row);
      table.add(tiCurrentPassword, 2, row);
    }

    row++;
    table.add(tNewPassword, 1, row);
    table.add(tiNewPassword, 2, row);

    row++;
    table.add(tNewPasswordRepeated, 1, row);
    table.add(tiNewPasswordRepeated, 2, row);

    row++;
    table.setHeight(row, 12);

    row++;
    table.mergeCells(1, row, 2, row);
    table.setAlignment(1, row, Table.HORIZONTAL_ALIGN_RIGHT);

    table.add(Text.NON_BREAKING_SPACE, 1, row);
    table.add(sbUpdate, 1, row);

    add(form);
  }