jsf 2 - ViewScope: Target the "right" composite component's object instance -


jsf 2 Understanding the scope of the view scope and moving down, I'm running into problems again

There are many instances of bound object of my composite component and the values ​​set do not target "true".

I have the same initial setup as

I have now created a Composite Component:

   & Lt; / Mixed: Implementation & gt;   

and its Java equivalent

  @FacesComponent (value = "helloWidget") extends the public class HelloWidget UINamingContainer implies Serializable {Private Static FINAL} Long serialVersionUID = 2L; Private boolean visible; Public Zero Show () {System.out.println ("Setting the true state to visible state" +); Visible = true; } Public Zero Hide () {System.out.println ("Setting a visible position false" +); Visible = false; } Get the visible position of the public string getVisibleState () {System.out.println ("" + + "(" + visible + "); Return String.valueOf (visible);}}   

I then upgraded my ViewBean.java

  private HelloView widget; Private Boolean viewable; Get public stringViewSTest () {return String.valueOf (visible);} Public zero operation Show (ActionEvent ae) {visible = true; helloWidget.show ();} Public Zero Action (Action Avenue) {visibl E = false; helloWidget.hide ();} Public HelloWidget getHelloWidget () {Returns Halo Widget;} Public Zero SetHoloVijet (HelloVijet Hello Widget) {this.helloWidget = helloWidget;}   

My hello.xhtml:

   View> gt; & lt; h: form & gt; & lt; h: output text value = "visual-scod bean visual value: # {ViewBean.visibleState} "/>  & lt; mycc: halovidt binding =" # {visual bean. Hilo videt} "/> 
Lt; H: value of the command button = "show" functionalist = "# {viewBean.actionShow}" /> & Lt; H: command button value = "hide" action = author # "# {viewBean.actionHide}" /> & Lt; / H: form & gt; & Lt; / Ch: view & gt;

When I now press the Show / Hide buttons, the value of the "visible" property in the view varies as expected from the "visible" value of the HelloWidget property also varies , But when the page is displayed, a different Helloovist instance is shown, which appears to be set to false (default).

Am I doing wrong here? Is there any problem in binding composite component?

Components are immediately created during the creation / restoration, they were essentially requested in this manner. Are there. Any state that you want to keep in the field of view, needs to be stored in the JSF view state. The general view is that the recipients of the properties / properties represent the properties that see state representatives.

Then, it should:

  @FacesComponent (value = "HelloVidgett") Implementing the UINNING CONTAINER Public Square HALOVIDATE SerialJobile {Personal Stable FINAL LONG SERIAL VISIONIOUID = 2 L; Public Zero Show () {Set Vivek (true); } Public Zero Hide () {Set Visible (false); } Public Boolean Meetings Appropriate () {Return (Boolean) getStateHelper () Eval ("visible"); } Public Zero Setwizible (Boolean Visible) {getStateHelper (). Put ("visible", visible); }}   

However, there is no other potential problem related to this problem: Bean property using binding on a view that causes the view Use the binding attachment with extreme care during every request removed from Bean to rebuild this problem as it has already been explained.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -