Menu

Error:Duplicate model item property: relevant

Help
k w
2008-04-29
2013-04-15
  • k w

    k w - 2008-04-29

    Here is my code, I don't understand why i am getting this error:

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xml:lang="en">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>

        <script type="text/javascript" src="FormFaces/formfaces.js"></script>

        <xf:model id="_model">
          <xf:instance id="_data" src="userform.xml" />
          <xf:instance id="_state">
            <state>
              <displayControls>false</displayControls>
            </state>
          </xf:instance>
         

          <xf:bind nodeset="instance('state')/displayControls" id="showControls" relevant=".='true'" />
        </xf:model>

      </head>
     
      <body>
        <xf:group bind="showControls">
          <xf:label>Showing Controls</xf:label>
        </xf:group> 
      </body>
     
    </html>

     
    • John Kugelman

      John Kugelman - 2008-04-29

      Couple of problems:

      1. Your <state> and <displayControls> elements are inheriting the XHTML namespace from the <html> root element. You can fix that with <state xmlns="">...</state>

      2. Your instance() call references 'state' rather than '_state'.

      3. There's a bug in FormFaces triggered by setting the @relevant property on a <bind> that has an empty node-set (which yours does due to problems #1 and #2). To fix it I edited line 52 in Source/xforms/dependencyGraph.js to read:

      -     if (property != "text") {
      +     if (property != "text" && vertex.node != XFormBind.nonRelevantNode) {
              throw new XmlException("Duplicate model item property: " + property);
            }

      If you make this change you can then generate a new formfaces.js loading Release/index.html in your web browser.

      Hope that helps!

      John

       
    • k w

      k w - 2008-04-29

      Hey John,

      I made the required changes for 1-3, but I do not have the Release/index.html to recompile the new js.  I am looking within my FormFaces dir, maybe this is not the right place.

      Thanks for your time,

      Kev

       
      • John Kugelman

        John Kugelman - 2008-04-30

        Darn, it's not included in our download. You can get it from our CVS repository, though.

        I've uploaded an updated formfaces.js with this fix here:

        http://www.formfaces.com/faces/formfaces.js

        Let me know if that works. I haven't logged on to our webserver and updated anything in a while, not sure if I did it right... :-/

         
    • k w

      k w - 2008-04-30

      Thanks for the fix John,

      However, I don't think 'relevant' is working properly.  From my understanding, relevant enables creation of dynamic apps which use model-based switching to create conditional UI's.  When a node has its relevant property set to false, the bound UI controls are suppose to become unavailable to the user, eg. they will not be shown.  When I run the following code, I can still see 'it works'...

          <xf:model id="userform_model">
            <xf:instance id="data" src="userform.xml" />
            <xf:instance id="localState">
              <state xmlns="">
                <displayRadioControls>false</displayRadioControls>
              </state>
            </xf:instance>

            <xf:bind id="showRadioControls" nodeset="instance('localState')/displayRadioControls" relevant="boolean-from-string(.)" />     

          </xf:model>
      </head>
        <body>
          <div>
            <xf:group bind="showRadioControls">
              <xf:label>it works</xf:label>
            </xf:group>
          </div>   
        </body>

       
      • John Kugelman

        John Kugelman - 2008-04-30

        Ah yes, I neglected to mention that you also need a style rule to hide non-relevant controls. FormFaces dynamically adds the "xforms-disabled" class to non-relevant controls, but there's no default styling to hide that class.

        The same thing applies to other MIPs. Here are some sample styles from Examples/Test Pages/xforms.css:

        .xforms-disabled {
          display: none;
        }

        .xforms-read-only input {
          background: #AAA;
        }

        .xforms-invalid .xforms-label {
          color: red;
        }

        .xforms-required label {
          font-weight: bold;
        }

        John

         
    • k w

      k w - 2008-04-30

      Awesome, thank you.

      -Kev

       

Log in to post a comment.