Subversion Repositories general

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1242 dev 1
package ak.photoalbum.webapp;
2
 
3
import javax.servlet.http.HttpServletRequest;
4
import org.apache.struts.action.ActionError;
5
import org.apache.struts.action.ActionErrors;
6
import org.apache.struts.action.ActionForm;
7
import org.apache.struts.action.ActionMapping;
8
 
9
public class IndexForm
10
  extends PathForm
11
{
12
  protected String page;
13
  protected int    pageInt;
14
 
15
  public String getPage()
16
  {
17
    return page;
18
  }
19
 
20
  public int getPageInt()
21
  {
22
    return pageInt;
23
  }
24
 
25
  public void setPage(String page)
26
  {
27
    this.page = page;
28
  }
29
 
30
  public ActionErrors validate(ActionMapping mapping,
31
    HttpServletRequest request)
32
  {
33
    ActionErrors errors = new ActionErrors();
34
 
35
    try {
36
      pageInt = (page == null) ? 0 : Integer.parseInt(page);
37
    }
38
    catch(Exception ex) {
39
      errors.add(null, new ActionError("Cannot parse page number"));
40
    }
41
 
42
    if(errors.size() == 0) {
43
      if(pageInt < 0)
44
        errors.add(null, new ActionError("Wrong page number"));
45
    }
46
 
47
    return errors;
48
  }
49
}