JSF cyclic control detection error

I have pages A and B, I want to go from A to B and back from B to A in JSF. I set the managed property B to the managed bean A and vice versa, but the problem is that I got an error, such as MANAGED bean CYCLE DETECTION.

  <managed-bean>
      <managed-bean-name>viewBulkMetalIssueBean</managed-bean-name>
      <managed-bean-class>com.cc.jas.web.manufacturing.bulkmetalissue.ViewBulkMetalIssueBean</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
      <managed-property>
       <property-name>viewJobcardBean</property-name>
       <property-class>com.cc.jas.web.manufacturing.jobcard.ViewJobcardBean</property-class>
       <value>#{viewJobcardBean}</value>
       </managed-property>


     </managed-bean>


    <managed-bean>
      <managed-bean-name>viewJobcardBean</managed-bean-name>
      <managed-bean-class>com.cc.jas.web.manufacturing.jobcard.ViewJobcardBean</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
       <property-name>viewBulkMetalIssueBean</property-name>
       <property-class>com.cc.jas.web.manufacturing.bulkmetalissue.ViewBulkMetalIssueBean</property-class>
       <value>#{viewBulkMetalIssueBean}</value>
       </managed-property>


      </managed-bean>

Is there any solution or alternative solution to this problem?

+3
source share
2 answers

This is really impossible. Without this discovery, this will only lead to an endless set-up of managed property.

To get around this, simply put the "parent" bean in the "child" bean when it was introduced.

public class Parent {
    private Child child;

    public void setChild(Child child) {
        this.child = child;
        this.child.setParent(this);
    }

    // ...
}

WITH

<managed-bean>
    <managed-bean-name>parent</managed-bean-name>
    <managed-bean-class>com.example.Parent</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
        <property-name>child</property-name>
        <property-class>com.example.Child</property-class>
        <value>#{child}</value>
    </managed-property>
</managed-bean>

<managed-bean>
    <managed-bean-name>child</managed-bean-name>
    <managed-bean-class>com.example.Child</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
+13
source

JSF beans. MyFaces wiki.

- java- bean EL- ( JSF 1.2):

ELContext elContext = FacesContext.getCurrentInstance().getELContext();
NeededBean neededBean = (NeededBean) FacesContext.getCurrentInstance().getApplication()
    .getELResolver().getValue(elContext, null, "neededBean");

. - MyFaces, JSF.

+2

Source: https://habr.com/ru/post/1776626/


All Articles