0

I have a spring form, with backing object that includes a LazyList - works hunky dory.

The form initally shows:

<tr><td>
<form:textarea path="myList[0]" cssClass="myClass" rows="2" cols="35"/>
</td><tr>
<tr><td>
<form:textarea path="myList[1]" cssClass="myClass" rows="2" cols="35"/>
</td><tr>

When a user focusses on the final textarea I want another one to be appended. The html and javascript I have OK, its the binding to the spring backing object that is a problem, my javascript so far:

var myStr =  '<tr><td>'+
    '<form:textarea path="myList[2]" cssClass="myClass" rows="2" cols="35"/>'+
    '</td><tr>'     

function myAppend(){
jq('#myTable tr:last').find("textarea").unbind('focus');
jq('#myTable tr:last').after(myStr);
jq('#instructionTable tr:last').find("textarea").bind('focus', function() {
    myAppend();
    });
}

However the rendering is screwed up ... any tips ?

I've found this, which performs and ajax call for each new line. Is their any other option ?

3

1 Answer 1

1

The spring <form:textarea ... /> tag is evaluated on server side. It renders the according HTML Element based on the given tag parameters. So a:

<form:textarea path="name"/>

is rendered to

<textarea id="name" name="name"></textarea>

So you have to append a <textarea /> Element with your javascript.

The reason for using the tag is to bind the submited value to the 'commandBean' provided by your spring controller.

Sign up to request clarification or add additional context in comments.

2 Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.