On Tue, May 19, 2009 at 17:14, Jim Kiley <jhki...@summa-tech.com> wrote:
> You could access category with #session.category if I remember my OGNL
> right.   Or you could add a 'category' field to your Action class, with
> public getter and setter, and then, instead of putting cat into the session,
> you could do this.setCategory(cat) -- and then your JSP would work fine.
>
in previous version i've done whith a parameter. but if there's an
automatic error discovered by struts the categories disappears.

ognl don't check automatic inside session?

> On Tue, May 19, 2009 at 11:02 AM, Stefano Tranquillini <
> stefano.tranquill...@gmail.com> wrote:
>
>> 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
>>
>>
>
>
> --
> Jim Kiley
> Senior Technical Consultant | Summa
> [p] 412.258.3346
> http://www.summa-tech.com
>



-- 
Stefano

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

Reply via email to