• Post Reply Bookmark Topic Watch Topic
  • New Topic

Binding components and setting ValueExpression

 
Vasilis Souvatzis
Ranch Hand
Posts: 81
1
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day! I'll start by saying that this post is a followup to this one. It has the working code, so I won't litter this thread by repeating it. But to briefly explain what I want to do I'll say this; dynamically create tabs by pressing a button, each tab has Primefaces input texts in which i'll be adding stuff and with a Submit button i'm submitting the form.

My issue now is this; although I can create more buttons through my managed bean, I cannot set the ValueExpression to the InputTexts. When I do:
it doesn't work.

The createValueExpression is a static method in my managed bean and it returns a ValueExpression. I'm most certain I found it online, not sure where though, it's been over a month since the last time I worked with this topic.

Anyway, is my whole "methodology" correct? Should I do anything differently? Can you see any errors in my way of doing?
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, my number 1 rule for JSF is that the more JSF-specific your solution is, the more likely it's not a good one. Although if you're dynamically creating elements, you may need to do it that way.

What I suspect is the problem is that you think that simply setting the value expression is sufficient. It isn't. Setting the value expression creates a binding between a UI element and a backing bean property, but it does not update the display. You'd also have to initiate rendering of the display element.
 
Vasilis Souvatzis
Ranch Hand
Posts: 81
1
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Tim, sorry for the late response.

Tim Holloway wrote:Well, my number 1 rule for JSF is that the more JSF-specific your solution is, the more likely it's not a good one.

Could you elaborate on this one with a generic example? I'm really intrigued now and it seems like a solid advice.

Tim Holloway wrote:What I suspect is the problem is that you think that simply setting the value expression is sufficient. It isn't. Setting the value expression creates a binding between a UI element and a backing bean property, but it does not update the display. You'd also have to initiate rendering of the display element.

Oh my god, is it really that simple... I'm not on my laptop now, will check later and report back.
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This forum is littered with all sorts of atrocities committed by people who felt that JSF should be more complicated than it is.

Well, actually, JSF is pretty complicated, but a lot of that complexity is there to ensure that what the developer has to code won't have to be complicated.

Just search the forum for "Rule #1" and I think you'll see what I mean.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!