Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf h:commandButton部分刷新无法工作_Jsf_Jsf 2 - Fatal编程技术网

Jsf h:commandButton部分刷新无法工作

Jsf h:commandButton部分刷新无法工作,jsf,jsf-2,Jsf,Jsf 2,我是JSF新手,我很难在JSF2.2中实现部分刷新/呈现,我使用的是.xhtml页面,我已经在Internet上搜索了解决方案,但无法工作。我的做法错了吗 这是我的密码: <h:form> <div class="container"> <div class="section"> <!-- Icon Section --> <h:panelGroup id="result" styleClass=

我是JSF新手,我很难在JSF2.2中实现部分刷新/呈现,我使用的是.xhtml页面,我已经在Internet上搜索了解决方案,但无法工作。我的做法错了吗

这是我的密码:

<h:form>
  <div class="container">
    <div class="section">

      <!--   Icon Section   -->
      <h:panelGroup id="result" styleClass="row">
        <ui:repeat var="project" value="#{homeBean.displayProjectList}">

          <div class="col s12 m6 l4">
            <div class="card">
              <div class="card-image">
                <img src="resources/materialize/background1.jpg" />
                <span class="card-title">#{project.title}</span>
              </div>
              <div class="card-content">
                <p>#{project.summary}</p>
              </div>
              <div class="card-action">
                <a href="./event.xhtml">More</a>
              </div>
            </div>
          </div>

        </ui:repeat>
      </h:panelGroup>


      <div class="row center">
        <h:commandButton styleClass="btn-large yellow lighten-2 black-text" value="SHOW MORE" actionListener="#{homeBean.showMore()}" >
          <f:ajax render="result" />
        </h:commandButton>

      </div>

    </div>
  </div>
</h:form>

#{project.title}
#{project.summary}

按下命令按钮时,我只希望刷新panelGroup id=“result”中包含的部分,它确实更新了,但我只希望刷新部分而不是整个页面


非常感谢您花费的时间和精力。

将actionListener从h:commanButton中删除,并将listener放入f:ajax中,然后再试一次。

这对我来说很好,应该可以工作。您确定整个页面正在刷新吗


应该可以做到这一点

我找到了答案,在我的例子中,我通过导入
javax.faces-2.2.7.jar
使用JSF2.2,我应该在
head
标记中设置以下outputScript声明

<h:outputScript library="javax.faces" name="jsf.js" target="head" />

现在,它的作用就像魅力一样

参考:


只有几件事,您不一定需要commandButton中的
actionListener
,动作是好的。您不必添加额外的
,为
定义一个id,并在
标记的渲染属性中使用该id。我知道您还没有足够的声誉发表评论,但请不要以此为借口发表评论作为答案。这篇文章根本没有回答具体的问题。我理解,很抱歉。只是想帮忙!我对你的意图毫无疑问。将来,在发布答案之前,最好尝试在沙箱项目中重现所描述的问题。如果您找到了原因和解决方案,请尝试详细描述问题的原因,并解释建议的解决方案是如何解决问题的。这也是学习新事物的好方法。也就是说,当前的答案是完全错误的,只是在黑暗中拍摄。在webbrowser中按F12打开webdeveloper工具集。当客户端出现故障时,您通常会在那里找到线索。很有可能在控制台中会看到一条简单的(而且非常谷歌化的)JS错误消息。谢谢@BalusC你的方法真的帮助我找到了答案,直到我使用chrome的开发工具,我才看到错误“Majara是未定义的”错误。非常感谢你,我会为我的案子贴出答案的。请注意,只要您有一个
而不是
,就不需要显式地包含该脚本。