Subversion Repositories general

Rev

Rev 1242 | Details | Compare with Previous | 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.ActionMapping;
7
 
8
public class IndexForm
9
  extends PathForm
10
{
11
  protected String page;
12
  protected int    pageInt;
13
 
14
  public String getPage()
15
  {
16
    return page;
17
  }
18
 
19
  public int getPageInt()
20
  {
21
    return pageInt;
22
  }
23
 
24
  public void setPage(String page)
25
  {
26
    this.page = page;
27
  }
28
 
29
  public ActionErrors validate(ActionMapping mapping,
30
    HttpServletRequest request)
31
  {
32
    ActionErrors errors = new ActionErrors();
33
 
34
    try {
35
      pageInt = (page == null) ? 0 : Integer.parseInt(page);
36
    }
37
    catch(Exception ex) {
38
      errors.add(null, new ActionError("Cannot parse page number"));
39
    }
40
 
41
    if(errors.size() == 0) {
42
      if(pageInt < 0)
43
        errors.add(null, new ActionError("Wrong page number"));
44
    }
45
 
46
    return errors;
47
  }
48
}