Figuring out if there were type conversion errors was something we ran into. 
The bigger issue for us was validation.  There is no easy way to do field
level validation with an editable grid.  (Or I haven't seen a good example
of one)


Josh Vickery-2 wrote:
> 
> You can do this with Struts 2, but I've found that it can be a bit
> hairy when it comes to type conversion.  The general idea is to use an
> action property which is a Map of objects that you want to save keyed
> by a unique identifier for each one.  The two problems that I run into
> when doing this are:
> 
> 1.  The view syntax -- accessing properties in a map using OGNL,
> struts tags, JSTL, and/or JSP EL can be confusing, and I sometimes
> find that a mixture of all of the above is needed for at least
> somewhat concise code.  I often find that I need to look at the
> rendered source of a page in order to figure out how to get the values
> from the page setup action properly displayed, and the user input
> values correctly and safely submitted to the post action.
> 
> 2.  Type conversion -- even after I think I have the submit value
> correct, I sometimes find that Struts 2 does not do type
> conversion/action property population as I expect.  In order to get
> this sorted out, I rely on a debugger, and make sure the debugger has
> access to the Struts 2 and Xwork source (yay open source!)
> 
> For example, say you had a set of questions that you wanted to make
> editable, you might do something like this:
> 
> QuestionSetupAction:
> private List<Question> questionList;
> public void setQuestionList(List<Question> questionList)...
> public List<Question> getQuestionList()...
> public String execute() {
>   questionList = questionDao.findQuestions();
>   return SUCCESS;
> }
> 
> QuestionEdit.jsp:
> <s:form action="questionPost">
> <s:iterator value="questionList">
>   <s:textfield name="questionMap[%{id}].questionText"
> value="questionText"/>
> </s:iterator>
> <s:submit/>
> </s:form>
> 
> QuestionPostAction:
> private Map<Long, Question> questionMap;
> public void setQuestionMap(Map<Long, Question>)...
> public Map<Long, Question> getQuestionMap()...
> 
> If you want to get fancy, you can use javascript to make any cell on
> your table editable on click, and submit any change to the server
> using ajax.  This doesn't really buy you all that much, unless you
> have lots and lots of rows and columns, in which case you could
> greatly cut the amount of data you need to sort through in the post
> action.
> 
> Josh
> 
> On 10/15/07, wild_oscar <[EMAIL PROTECTED]> wrote:
>>
>> Imagine a table with a List of items (say, a List of people, each with an
>> ID,
>> Name and age). I am thinking about developing a way to make all rows
>> editable and able to be saved simultaneously with a single submit button.
>>
>> Specifically, each item (Person, in the example) is an object mapped with
>> hibernate (although this feature should be independent of the persistent
>> media). And ideally, the method should be smart enough to detect  on
>> which
>> rows there were changes and only update these rows.
>>
>> Has anyone ever developed such a table, or knows of a strategy to
>> implement
>> it?
>> --
>> View this message in context:
>> http://www.nabble.com/GridView---save-multiple-items-at-the-same-time-tf4625630.html#a13209261
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/GridView---save-multiple-items-at-the-same-time-tf4625630.html#a13213826
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to