Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Saving objects/beans on form's members using struts tags?

Francesco Pretto

2007-03-26


Ok, suppose i have my usual form "MyForm", an ArrayList "listofT",
with objects of type T, and a field "fieldT" of type T. Is possible to
pass an object (not a string fields) of "ListofT" in the fieldT
directly, using only struts tags an nothing more (Javascript/Ajax), or
this is only Science Fiction?

Some conceptual sample code: a very common taks, a select that populate a field:

<bean:define id="BeanListofT" name="MyForm" property="listofT"/>
<html:select property="fieldT" >
    <html:options name="BeanListofT" />
</html:select>

This code actually works somewhat: "BeanListofT" is iterated, value
and label fields in rendered html are filled with
BeanListofT[i].toString(), as the usual behavior. Submitting the form
obviously cause a "Type mismatch" error.

What would be really cool, IMO, would be the possibility of issuing
the assign of the fieldT ( fieldT = BeanListOfT[i], or with a "new" )
directly from the HTML. Does this possibility exist or, as i suppose,
am i only dreaming?

Thanks,
Francesco

(please, don't let this msg unanswered. If it's the case, just leave a
"it's impossible" or "you are dreaming".)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.