How can I bind props:textarea value to its content in JSP?

I am working on a JSP file that has the following node:

<tr id="artifactVersionXmlRow">
<th><label for="${bean.artifactVersionXml}">Artifact Version XML Path:</label></th>
<td>
<div class="completionIconWrapper">
<props:textProperty name="${bean.artifactVersionXml}" className="longField" />
<bs:vcsTree fieldId="${bean.artifactVersionXml}" />
</div>
<span class="error" id="error_${bean.artifactVersionXml}"></span>
<span class="smallNote">Specify path to the artifact version XML</span>
</tr>

My task is to enable storing multiple XML file names instead of just one. So I considered using props:textarea instead of props:textProperty,

There are two problems with that:

  1. props:textarea has a required property called value and whatever I put in that property always overwrites whatever value is entered in the compiled page. How can I bind this property to the saved content?
  2. bs:vcsTree is great for props:textProperty because it overwrites the selected content, which is just what is needed in the case of a single XML file name. However, when selecting multiple files, bs:vcsTree deletes all the file names that have been selected so far, which can be pretty annoying. How can this be fixed? Are props:textarea and bs:vcsTree the best approach here or is there a more suitable solution?

Thanks,

Itai

0
2 comments

Unfortunately it is not that clear, but textArea is a bit low level custom tag. If you want multi line value, then consider using multilineProperty tag instead.

For instance, this is how it is being used for Ant "Build file content" field:

 <tr>
<th>
<c:set var="onclick">
if (this.checked) {
try {
BS.MultilineProperties.show('build-file', true);
$('build-file').focus();
} catch(e) {}
}
</c:set>
<props:radioButtonProperty name="use-custom-build-file" value="true" id="custom2" onclick="${onclick}"/>
<label for="custom2">Build file content:</label>
</th>
<td>
<props:multilineProperty expanded="${propertiesBean.properties['use-custom-build-file'] == true}" name="build-file" rows="10" cols="58" linkTitle="Enter the build file content" onkeydown="$('custom2').checked = true;" className="longField"/>
</td>
</tr>

You probably don't need this complex logic, but example just shows how you can work with this field from JS.

1

Thanks, Pavel, multilineProperty did the job.

0

Please sign in to leave a comment.