English 中文(简体)
JSF <h:commandButton> with <f:ajax> notborn on @ViewScoped bean but <a4j:ajax> work
原标题:JSF <h:commandButton> with <f:ajax> not executed on @ViewScoped bean but <a4j:ajax> works

我在<代码>/subviews/document-tree.xhtml上有一个面观子,使每个表上的树木在<代码>和t;rich:tabPanel>的客户。 该网页和次观点基于共同财产法2和RichFaces4。

<ui:composition ...>
  <rich:tree value="#{rootNode}" var="treeNode" id="#{treeId}">

    <rich:treeNode ... id="chapternode">

      <h:panelGrid columns="2">
        <rich:outputText value="#{treeNode.name}" />
        <h:commandLink>
          <h:graphicImage library="images/icons" name="delete.png"  />
          <rich:componentControl target="remove-chapter-popup" operation="show" />
        </h:commandLink>
        <rich:popupPanel modal="true"
                         onmaskclick="#{rich:component( remove-chapter-popup )}.hide(); return false;"
                         id="remove-chapter-popup">
          <f:facet name="header">
            <h:outputText value="Remove chapter?" />
          </f:facet>
          <f:facet name="controls">
            <h:outputText value="X" />
          </f:facet>
          <p>Remove chapter #{treeNode.name}?</p>
          <h:panelGrid columns="2">
            <h:commandButton value="Add"
                             action="#{nodeManager.removeChapterNode(treeNode)}" 
                             onclick="#{rich:component( remove-chapter-popup )}.hide(); return true;">

              <!--f:ajax execute="@this" render="@form" /-->        <!-- never executed! -->
              <a4j:ajax execute="@this" render="@form" />           <!-- this works however! -->

            </h:commandButton>
            <h:commandButton value="Cancel"
                             onclick="#{rich:component( remove-chapter-popup )}.hide(); return false;" immediate="true" />
          </h:panelGrid>
        </rich:popupPanel>
      </h:panelGrid>

    </rich:treeNode>

    ...

  </rich:tree>
</ui:composition>

这基本上表明树苗的名称加上删除权的形象。

每一树次观点均载于<代码><rich:tab>,因此,表格小组does 具有必要的封面内容,<h:form>。 没有任何其他封不动的形式(隐蔽的通道)。

The #{nodeManager.removeChapterNode(treeNode)} bean was correctly marked as @ViewScoped.

现在的情况是奇怪的:

在使用<代码><f:ajaxpet="@this” ....../>,never, 而使用<代码><a4j:ajax Implement="@this”...... />>>m>always。

Why? 这里有什么错误?

鉴于RichFaces <a4j:ajax>以100%为基础,以JF 2 <f:ajax>为依据。

Could it be a bug in JSF 2.1.7, which I m used? (与JBosss AS 7.1.1.Final一起执行)

最佳回答

Here s the reduced diff:

<form id="tree-form" name="tree-form" method="post" action="/pqgenerator2/debug.jsf" enctype="application/x-www-form-urlencoded">
 ...
  <table style="margin: 0 auto;">
    <tbody>
      <tr>
- <td><input id="tree-form:sorting-tree-one:real root:j_idt34" type="submit" name="tree-form:sorting-tree-one:real root:j_idt34" value="Fortfahren" onclick="jsf.util.chain(this,event, RichFaces.$( tree-form:sorting-tree-one:real root:add-root-chapter-popup ).hide(); return true; , mojarra.ab(this,event, action , @this tree-form:sorting-tree-one:real root:new-root-chapter-name-input , @form ) );return false" /></td>
+ <td><input id="tree-form:sorting-tree-one:real root:j_idt34" type="submit" name="tree-form:sorting-tree-one:real root:j_idt34" value="Fortfahren" onclick="jsf.util.chain(this,event, RichFaces.$( tree-form:sorting-tree-one:real root:add-root-chapter-popup ).hide(); return true; , RichFaces.ajax(this,event,{&quot;parameters&quot;:{&quot;javax.faces.behavior.event&quot;:&quot;action&quot;,&quot;org.richfaces.ajax.component&quot;:&quot;tree\u002Dform:sorting\u002Dtree\u002Done:real root:j_idt34&quot;} ,&quot;sourceId&quot;:this} ) );return false" /></td>
      </tr>
    </tbody>
  </table>
...

- </div></span></span></div></div><input type="hidden" name="tree-form:sorting-tree-one__SELECTION_STATE" id="tree-form:sorting-tree-one__SELECTION_STATE" class="rf-tr-sel-inp" value="" /><script type="text/javascript">new RichFaces.ui.Tree("treeu002Dform:sortingu002Dtreeu002Done",{"toggleType":"client"} );</script></div></div><script type="text/javascript">new RichFaces.ui.Tab("treeu002Dform:j_idt21",{"index":0,"leave":null,"togglePanelId":"treeu002Dform:treeu002Dtabpanel","switchMode":"client","name":"Blah GmbH","enter":null,"disabled":false} )</script></div><script type="text/javascript">new RichFaces.ui.Tab("treeu002Dform:j_idt21",{"index":0,"leave":null,"togglePanelId":"treeu002Dform:treeu002Dtabpanel","switchMode":"client","name":"Blah GmbH","enter":null,"disabled":false} )</script></div><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="998210192617713914:-9142017502724223608" autocomplete="off" />
+ </div></span></span></div></div><input type="hidden" name="tree-form:sorting-tree-one__SELECTION_STATE" id="tree-form:sorting-tree-one__SELECTION_STATE" class="rf-tr-sel-inp" value="" /><script type="text/javascript">new RichFaces.ui.Tree("treeu002Dform:sortingu002Dtreeu002Done",{"toggleType":"client"} );</script></div></div><script type="text/javascript">new RichFaces.ui.Tab("treeu002Dform:j_idt21",{"index":0,"leave":null,"togglePanelId":"treeu002Dform:treeu002Dtabpanel","switchMode":"client","name":"Blah GmbH","enter":null,"disabled":false} )</script></div><script type="text/javascript">new RichFaces.ui.Tab("treeu002Dform:j_idt21",{"index":0,"leave":null,"togglePanelId":"treeu002Dform:treeu002Dtabpanel","switchMode":"client","name":"Blah GmbH","enter":null,"disabled":false} )</script></div><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-5805340602741883884:1908800949269113937" autocomplete="off" />
</form>

这里的问题是,我创立了要展示的RichFaces根的 du子,我通过RichFaces(Tree NodeImpladdChild(“real fundamental”)添加了真正的根基,其中包含了钥匙的空间。

<代码><a4j:ajax> 法典显然可以处理这一条,但不能处理《共同法》第2条:<编码>和>;f:ajax>(脚注第一部分)。

问题回答

空间在IDs中是非法的。 See also UIComponent#setId() javadoc.

setId

public abstract void setId(java.lang.String id)

(如果有的话) 部件识别器必须服从下列yn类限制:

  • Must not be a zero-length String.
  • First character must be a letter or an underscore ( _ ).
  • Subsequent characters must be a letter, a digit, an underscore ( _ ), or a dash ( - ).

构成部分识别符号也必须遵守下列属人限制(指出这一限制是由<代码>setId(执行)实施的NOT):

  • The specified identifier must be unique among all the components (including facets) that are descendents of the nearest ancestor UIComponent that is a NamingContainer, or within the scope of the entire component tree if there is no such ancestor that is a NamingContainer.

<>光线>

  • id - The new component identifier, or null to indicate that this UIComponent does not have a component identifier

<>Throws:

  • IllegalArgumentException - if id is not syntactically valid

象RichFaces这样的种子从来没有根据树木规则加以验证。 反过来,我会把它看作是RichFaces的ug。 Report, 发给RichFaces guys。





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签