01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.components;
06:
07: import com.opensymphony.webwork.components.Param.UnnamedParametric;
08: import com.opensymphony.xwork.util.OgnlValueStack;
09:
10: import javax.servlet.http.HttpServletRequest;
11: import javax.servlet.http.HttpServletResponse;
12: import java.util.ArrayList;
13: import java.util.List;
14:
15: /**
16: * <!-- START SNIPPET: javadoc -->
17: *
18: * Render field errors if they exists. Specific layout depends on the particular theme.
19: *
20: * <!-- END SNIPPET: javadoc -->
21: *
22: * <p/> <b>Examples</b>
23: *
24: * <pre>
25: * <!-- START SNIPPET: example -->
26: *
27: * <!-- example 1 -->
28: * <ww:fielderror />
29: *
30: * <!-- example 2 -->
31: * <ww:fielderror>
32: * <ww:param>field1</ww:param>
33: * <ww:param>field2</ww:param>
34: * </ww:fielderror>
35: * <ww:form .... >>
36: * ....
37: * </ww:form>
38: *
39: * OR
40: *
41: * <ww:fielderror>
42: * <ww:param value="%{'field1'}" />
43: * <ww:param value="%{'field2'}" />
44: * </ww:fielderror>
45: * <ww:form .... >>
46: * ....
47: * </ww:form>
48: *
49: * <!-- END SNIPPET: example -->
50: * </pre>
51: *
52: *
53: * <p/> <b>Description</b><p/>
54: *
55: *
56: * <pre>
57: * <!-- START SNIPPET: description -->
58: *
59: * Example 1: display all field errors<p/>
60: * Example 2: display field errors only for 'field1' and 'field2'<p/>
61: *
62: * <!-- END SNIPPET: description -->
63: * </pre>
64: *
65: *
66: * @author tm_jee
67: * @version $Date: 2006-01-01 16:16:03 +0100 (Sun, 01 Jan 2006) $ $Id: FieldError.java 1897 2006-01-01 15:16:03Z tmjee $
68: * @ww.tag name="fielderror" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.FieldErrorTag"
69: * description="Render field error (all or partial depending on param tag nested)if they exists"
70: */
71: public class FieldError extends UIBean implements UnnamedParametric {
72:
73: private List errorFieldNames = new ArrayList();
74:
75: public FieldError(OgnlValueStack stack, HttpServletRequest request,
76: HttpServletResponse response) {
77: super (stack, request, response);
78: }
79:
80: private static final String TEMPLATE = "fielderror";
81:
82: protected String getDefaultTemplate() {
83: return TEMPLATE;
84: }
85:
86: public void addParameter(Object value) {
87: if (value != null) {
88: errorFieldNames.add(value.toString());
89: }
90: }
91:
92: public List getFieldErrorFieldNames() {
93: return errorFieldNames;
94: }
95: }
|