As for collections, I tend to use custom collections for getting
updates from JSF. It isn't the cleanest solution by any means, but has
helped me out with the "limitations" of the EL language.

I have made wrappers something like (I am not at my work computer, so
can't bring up the exact code):

public class CustomMap<K,V> extends AbstractMap<K,V> {
public V put(K key, V value) {
 V prev = super.put(key, value);
 // do the business logic here
 return prev;
}

It ends up being a bit of a bean in itself, instead of just a
collection, but then you have the power to delegate business code when
binding updates a collection value.

Would be nice if there could be some binding interceptor with JSF that
could be applied to all components. The only way I know of with that
is a custom variable resolver. Perhaps that is what you want to do? I
am not sure all of what you are allowed to do with a variable
resolver, but you (maybe) could:

value="#{getter: bean.someProperty setter: bean.someOtherProperty}"

As I said, I'm not sure if you are allowed to "hack" the EL like this
or not, I can't recall at what level the engine leaves off and where
the variable resolver takes up.

Maybe you could use a JSTL stype function (if you are using facelets)
and write a function that has a return type of MethodBinding? Once
again I'm not sure if the specification would allow such a thing.

Just some other ideas, sorry that I don't know if any are feasible.

The other comment, you say you don't know what was replied to, could
you? Is it possible to use the myfaces updateActionListener to set the
selected post on the backing bean during post back?

-Andrew

On 5/21/06, benjamin van der veen <[EMAIL PROTECTED]> wrote:
I've been looking into the tag/component thing, and it seems like
rather a lot of work. The way I see it, I would have to reimplement
all of the tag/component/renderer groups where the component extends
UIInput, and that is a little ridiculous. Any suggestions for
alternatives?

benjamin

On 5/20/06, benjamin van der veen <[EMAIL PROTECTED]> wrote:
> This wouldn't quite work because the Posts are in a collection, and I
> don't know which one was replied to, so I wouldn't know which to get
> the content from.
>
> Probably the component idea is the best one.
>
> On 5/20/06, Andrew Robinson <[EMAIL PROTECTED]> wrote:
> > 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