So,
i've done this:
there's a init action that does:
    public String execute() throws Exception {
        Map session = ActionContext.getContext().getSession();
        List cat = mgmt.getAllCategory();
        session.put("category", cat);
        return SUCCESS;
    }

after that a jsp is display:

<%@ taglib uri="/struts-tags" prefix="s" %>

<s:form action="addItem" namespace="/admin" method="POST">
    <s:actionerror/>
    <s:textfield name="title" label="title" required="true"/>
    <s:select label="category"
              name="category"
              list="category"
              listKey="idCategory"
              listValue="name"
              multiple="false"
              headerValue="-- Please Select --"
              required="true"
              />

    <s:textarea cols="15" rows="5" name="desc" label="desc" required="true"/>
    <s:textfield name="prize" label="prize" required="true"/>
    <s:textfield name="quantity" label="quantity" required="true"/>
    <s:submit/>
</s:form>

but the problem is:

tag 'select', field 'list', name 'category': The requested list key
'category' could not be resolved as a
collection/array/map/enumeration/iterator type. Example: people or
people.{name} - [unknown location]

ideas?


On Sat, May 9, 2009 at 14:19, Stefano Tranquillini
<stefano.tranquill...@gmail.com> wrote:
>
>
> On Sat, May 9, 2009 at 00:49, Dave Newton <newton.d...@yahoo.com> wrote:
>>
>> Stefano Tranquillini wrote:
>>>
>>> i've a form. i've some field that are double type. if i put a string inside
>>> these fileds struts automatically check the incorrectness of the type. ok!
>>> but, inside this form i've a select that is created by a list.
>>> when the error comes out from struts, sruts goes back to the input page,
>>> the list become empty and in the page no item is display.
>>>
>>> how can i store the list in order to have its inside my page after the
>>> error?
>>
>> You could store it in session, you could implement Preparable and load the 
>> list. There are probably a few other reasonable solutions--those are what 
>> popped in to my head first.
>
> a ok, i thought about the same solution.
>
>>
>>> PS: if i set required="true" at a field, struts doesn't check if this value
>>> is present or not? what meaning has this property?
>>
>> From the documentation:
>>
>> "If set to true, the rendered element will indicate that
>> input is required"
>>
>> It displays a required indicator.
>
> so only display a * near the label
>>
>> Dave
>
> ciaociao
>
>
> --
> Stefano



--
Stefano

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

Reply via email to