Subversion Repositories general

Rev

Rev 1242 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package ak.photoalbum.webapp;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

public class IndexForm
  extends PathForm
{
  protected String page;
  protected int    pageInt;

  public String getPage()
  {
    return page;
  }

  public int getPageInt()
  {
    return pageInt;
  }

  public void setPage(String page)
  {
    this.page = page;
  }

  public ActionErrors validate(ActionMapping mapping,
    HttpServletRequest request)
  {
    ActionErrors errors = new ActionErrors();

    try {
      pageInt = (page == null) ? 0 : Integer.parseInt(page);
    }
    catch(Exception ex) {
      errors.add(null, new ActionError("Cannot parse page number"));
    }

    if(errors.size() == 0) {
      if(pageInt < 0)
        errors.add(null, new ActionError("Wrong page number"));
    }

    return errors;
  }
}