0

I'm referring to an answer here:

Why can't I get ViewScope to work? Throws errors every time

I didn't read view scope properly. You can only have one form per page. The bean is created multiple times if you have more than one form.

I can't confirm this. Can anybody please deny it? (if the quote above does apply, where's the appropriate reference for this?)

Thanks

Community
  • 1
  • 1
Kawu
  • 13,647
  • 34
  • 123
  • 195

1 Answers1

2

That is nonsense. OP's problem is caused by something else which has been reported as issue 2215.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks. I have to get rid of false info to solve problems with `@ViewScoped` beans and ``. So it should be safe to put the `` into the separate Facelets composition component... – Kawu Oct 23 '11 at 12:38
  • What kind of problems exactly? Are you binding a view scoped bean property to ``? If so read this: [@ViewScoped fails in tag handlers](http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#ViewScopedFailsInTagHandlers). – BalusC Oct 23 '11 at 12:50
  • I'm reading this document all the time. :-) It's just a static `` to a form that is passed values whether it's for creating a new instance or editing one. However, the update action on the command button gets fired only on the first click. For every subsequent click the update method isn't executed at all. I have to check whether my issue is the same as this: http://community.jboss.org/message/631936 and/or http://www.java.net/node/701117. Note that setting javax.faces.PARTIAL_STATE_SAVING to false is out of the question - I need drag'n drop https://issues.jboss.org/browse/RF-10967 – Kawu Oct 23 '11 at 13:20
  • I'Ve been inspecting this and it seems like `` has problems with dynamic constructs like `...`. I'm simply using `...`. Can you tell if that makes a difference?? (I know it's hard to discuss in SO comment boxes) – Kawu Oct 23 '11 at 14:41
  • 1
    Perhaps your problem is more related to [Ajax rendering of content which contains another form](http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichContainsAnotherForm). Hard to say without seeing a concrete question. – BalusC Oct 23 '11 at 14:50
  • No, I followed that post to make the create form work, which does respond to multiple creates. The create method is fired each time, update on another view-scoped bean and page isn't. PS: I've read your document multiple times (from top to bottom), there's nothing I missed, I'm sure. – Kawu Oct 23 '11 at 14:56
  • BalusC I read that a ViewScope is created once per form. I'm currently trying to find the reference. But over the course of trying to find the answer for my issue I came across it. Soon as I made the page one form it worked correctly. – Drew H Oct 24 '11 at 16:02
  • 1
    @Drew: No, it's created once per view. Try it youself with a simple view with 2 forms pointing to the same bean on a playground environment. You'll also see that the both `javax.faces.ViewState` hidden fields hold exactly the same value. Your problem was caused by something else. Your response just overflowed the buffer right before JSF creates the session. Removing and rearranging the view just by coincidence caused the response to be exactly within the buffer size and/or that JSF created the session before the response was committed. Follow the links in my answer and comments to learn more. – BalusC Oct 24 '11 at 16:13