You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Riyaz Mansoor <rm...@yahoo.com> on 2003/04/07 08:34:22 UTC

new to struts - basic questions

// sample class in javadocs struts 1.1
public class StringBean3 extends ActionForm {
    private String strAry[] =
    { "String 0", "String 1", "String 2", "String 3", "String 4" };
    private HashMap map = new HashMap();

    public StringBean() {
        map.put("zero", strAry[0]);
        map.put("one", strAry[1]);
        map.put("two", strAry[2]);
        map.put("three", strAry[3]);
        map.put("four", strAry[4]);
    }

    public Object getStringMapped(String key) { return (map.get(key)); }
    public void setStringMapped(String key, Object value)
    { map.put(key, value); }
}


in the above class would the key supplied by struts be the name of the
field/property of the HTML form? if not, what would it be?

i want to use a _composite_ object for the value/object stored in the map.
eg:
    String[] o1 = { "value", "type", "required=true" }
and the methods would be modifed to
    public Object getStringMapped(String key) { return
(((String[])map.get(key))[0]); }
    public void setStringMapped(String key, Object value)
    { String[] sa = (String[])map.get(key);
        sa[0] = value;
       map.put(key, sa); }

is this approach correct? why i want to do this, this way is that i can
write a single validation procedure (and even action - its a simple
application) dependeing on the field properties (type, required ...)

also, since using mapped form does not explicitly show which
properites/fields are used, how does struts figure out what values to put?
is it everything in the submitted form including submit buttons?

any potential problems with using File Upload from html forms with this
approach?

appreaciate your help

riyaz

ps: is mapped back forms available in struts 1.x ?




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org