You could accomplish this with a facade. I know it isn't what you are
exactly looking for, but would work.

Example (Using seam annotations):

@Name("postBean")
public class Post
{
 private String content;
 pubic String getContent() { return this.content; }
}

@Name("postResult")
pubic class ResultsBean
{
 private String newContent;
 public String getNewContent() { return this.newContent; }
 public void setNewContent(String content) { this.newContent = content; }
}

@Name("post")
public class PostFacade
{
 @In
 private Post postBean;
 @In(create=true)
 private ResutsBean postResult;

 public String getContent()
 {
   return (postResult.getNewContent() != null) ?
     postResult.getNewContent() :
     postBean.getContent();
 }

 public String setContent(String content) {
postResult.setNewContent(content); }
}

XHTML:
<t:inputTextarea value="#{post.content}" />

There are other ways, this is just the first that came to mind.

Another would obviously be a custom tag & component and handle the
decode in the way that you want.

-Andrew

On 5/20/06, benjamin van der veen <[EMAIL PROTECTED]> wrote:
Hello,

This is hard to articulate, so let me give an example:

Suppose you are making a message board. The objective is to make a
form the user can use to quote posts below his post, like so:

(user 3 sees this in a text area, and types something above it)

[begin textarea]

> user 2 said:
> second message
>
> > user 1 said:
> > original message
[end textarea]

In this example, user 3 is replying to a message from user 2, which
itself is a reply to a message from user 1.

The initial value of the text area comes from a Post object; I am
iterating (<ui:repeat>) through a collection of Posts to build the
topic view. However, when the user submits this form, I don't want the
value of the Post object to be updated, I want a separate field
(newPostContent) on my backing bean to be updated. The problem is
here:

<h:inputTextarea value="#{post.content}"/>

--I cannot specify that I want the inital value to come from one place
and I want the user-submitted value to go somewhere else. To give an
example of what such a thing might look like:

<h:inputTextarea initialValue="#{post.content}"
bindSubmittedValueTo="#{myBean.newPostContent}"/>

How would this be done in reality?

Thanks,
benjamin

Reply via email to