001: /*
002: * Copyright (c) 2006 Your Corporation. All Rights Reserved.
003: */
004:
005: package com.technoetic.xplanner.forms;
006:
007: import java.util.ArrayList;
008: import java.util.Iterator;
009: import java.text.MessageFormat;
010:
011: import javax.servlet.http.HttpServletRequest;
012:
013: import org.apache.struts.action.ActionErrors;
014: import org.apache.struts.action.ActionMapping;
015:
016: /**
017: * Created by IntelliJ IDEA.
018: * User: SG0897500
019: * Date: Mar 6, 2006
020: * Time: 11:58:37 AM
021: * To change this template use File | Settings | File Templates.
022: */
023: public class ReorderStoriesForm extends AbstractEditorForm {
024:
025: public static final String INVALID_ORDER_NUMBER = "story.editor.invalid.order.number";
026: private ArrayList storyIds = new ArrayList();
027: private ArrayList orderNos = new ArrayList();
028: private String iterationId;
029:
030: public ActionErrors validate(ActionMapping mapping,
031: HttpServletRequest request) {
032: ActionErrors errors = new ActionErrors();
033: if (orderNos != null) {
034: for (Iterator iterator = orderNos.iterator(); iterator
035: .hasNext();) {
036: String orderValue = (String) iterator.next();
037: try {
038: Double.parseDouble(orderValue);
039: } catch (NumberFormatException e) {
040: error(errors, INVALID_ORDER_NUMBER,
041: new Object[] { orderValue });
042: }
043: }
044: }
045: return errors;
046: }
047:
048: public ArrayList getStoryIds() {
049: return storyIds;
050: }
051:
052: public void setStoryIds(ArrayList storyIds) {
053: this .storyIds = storyIds;
054: }
055:
056: public void setStoryId(int index, String storyId) {
057: ensureSize(storyIds, index + 1);
058: storyIds.set(index, storyId);
059: }
060:
061: public String getStoryId(int index) {
062: return (String) storyIds.get(index);
063: }
064:
065: public int getStoryIdAsInt(int index) {
066: return Integer.parseInt(getStoryId(index));
067: }
068:
069: public int getStoryCount() {
070: return storyIds.size();
071: }
072:
073: public ArrayList getOrderNos() {
074: return orderNos;
075: }
076:
077: public void setOrderNos(ArrayList orderNos) {
078: this .orderNos = orderNos;
079: }
080:
081: public void setOrderNo(int index, String orderNo) {
082: ensureSize(orderNos, index + 1);
083: orderNos.set(index, orderNo);
084: }
085:
086: public String getOrderNo(int index) {
087: return (String) orderNos.get(index);
088: }
089:
090: public int getOrderNoAsInt(int index) {
091: return (int) Double.parseDouble(getOrderNo(index));
092: }
093:
094: public String getIterationId() {
095: return iterationId;
096: }
097:
098: public void setIterationId(String iterationId) {
099: this.iterationId = iterationId;
100: }
101:
102: }
|