Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Can you please post the Managed Bean code as well. From what I can see the <code>commentText</code> attribute in your <code>commentController</code> is a simple <code>String</code> instead of a <code>List&lt;String&gt;</code>. When you have for example three text areas you must have three different variables which should store the textarea content. This is why you need a list there.</p> <p><a href="https://stackoverflow.com/questions/9390910/saving-multiple-fields-in-the-same-managed-bean-property">Here</a> you can read some more details because I had the same problem as you.</p> <p>Knowing all that your code should look like this:</p> <p><strong>Managed Bean:</strong></p> <pre><code>private List&lt;String&gt; commentText; // get&amp; set </code></pre> <p><strong>Facelet:</strong></p> <pre><code>&lt;ui:repeat var="blogPost" value="#{blogPosts}" varStatus = "loop"&gt; &lt;h:form&gt; &lt;div class="full"&gt; &lt;label for="newComment" value = "Write a comment" /&gt; &lt;h:inputTextarea id = "newComment" value="#{commentController.commentText[loop.index]}" rows="10" cols="40" /&gt; &lt;/div&gt; &lt;div class="full"&gt; &lt;h:commandButton action="#{commentController.setComment()}" value="write comment" /&gt; &lt;/div&gt; &lt;/h:form&gt; </code></pre> <p></p> <p>Some other pointers:</p> <ul> <li>avoid that <code>&lt;br /&gt;</code> in the label tag.</li> <li>pay attention to the textarea <code>id</code> attribute. It should be the same as that linked by the label. If not, you will receive some view warnings because the framework will not be able to find the IDs you specified. Don't worry about the IDs being identical in the <code>ui:repeat</code> loop. If you analyse the HTML code you'll see that SF handle the IDs and they differ.</li> </ul> <p><strong>LE:</strong></p> <p>I think that the reason you are having this problem is that you allocated memory for the <code>List&lt;String&gt;</code> but the list does not contain any String. The framework wants to place values into the <code>List</code> but there is no <code>String</code> object to be setted.</p> <p>To solve this, in the <code>CommentController</code> you have to add the needed empty Strings into the List:</p> <pre><code>@PostConstruct protected void init(){ comment = new Comment(); commentTextListToWrite = new ArrayList&lt;String&gt;(); for (int i = 0; i &lt; blogPosts.size(); i++){ commentTextListToWrite.add(new String()); } } </code></pre> <p><code>blogPosts.size()</code> is the blogPosts attribute you are using on the <code>&lt;ui:repeat&gt;</code> tag. I can imagine that you are able to access it in the <code>CommentController</code> as well. This way, every time you instantiate a <code>CommentController</code> entity, the <code>commentTextListToWrite</code> will be instantiated and will contain the required number of empty Strings which will be completed on the view.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload