使H:panelGroup中点击,并发送回反复变 [英] Making h:panelGroup clickable, and send back repeated variable

查看:149
本文介绍了使H:panelGroup中点击,并发送回反复变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要点击一个 panelGrid中(男子已填充的对象列表中的一个),然后发送与它相关的支持bean的项目。

I need to make a panelGrid (one of man that are populated from a list of objects) clickable, and then send the item associated with it to the backing bean.

我的HTML,这样的:

My HTML so for:

<ui:repeat var="searchItem" value="#{bean.filteredSearchItems}" varStatus="searchResult">
    <h:panelGrid>
        <!-- I get some info here from the searchResult object -->
    </h:panelGrid>
    <f:ajax event="click" listener="{bean.clickFlight}" />
    <f:param name="lfi" value="#{searchResult.index}" />
</ui:repeat>

我知道(在我的支持bean),我需要 clickSearchItem()称为函数,可以处理Ajax调用,所以要测试这一切,我做了按照我的支持bean:

I know that (in my backing bean) I need a function called clickSearchItem() that can handle the ajax call, so to test all of this, I did the following in my backing bean:

public void clickFlight()
{
    HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String lfi = req.getParameter("lfi");

if (lfi == null)
    log.info("LFI WAS RETURNED AS NULL :(");

    log.info("HOPEFULLY AN INDEX OF SOME SORT!: " + lfi);
}

没有什么是越来越记录 - 点击不登记。任何人都有这个问题吗?有谁知道如何解决这个问题?

Nothing is getting logged - the click doesn't register. Has anyone else had this problem? Does anyone know how to solve it?

推荐答案

&LT; F:AJAX&GT; 需要嵌套到一个组件实施 ClientBehaviorHolder 。如果你打算使用&LT; H:panelGrid的&GT; (它生成一个HTML &LT;表&gt; )的是,那么你应该嵌套&LT; F:。AJAX&GT; 的组件本身

The <f:ajax> needs to be nested into a component implementing ClientBehaviorHolder. If you intend to use <h:panelGrid> (which generates a HTML <table>) for that, then you should be nesting the <f:ajax> in the component itself.

<h:panelGrid>
    <f:ajax event="click" listener="{bean.clickFlight}" />

    <!-- I get some info here from the searchResult object -->
</h:panelGrid>

&LT; F:参数&GT; H; 仅是通过渲染&LT承认:OUTPUTFORMAT&GT; &LT; H:commandXxx&GT; 。前提是你要定位一个Servlet 3.0兼容的容器(Tomcat 7的,Glassfish的3,JBoss的6/7,等等),它因此支持EL 2.2,那么你可以把它作为方法的参数,而不是:

The <f:param> is only recognized by renderer of <h:outputFormat> and <h:commandXxx>. Provided that you're targeting a Servlet 3.0 compatible container (Tomcat 7, Glassfish 3, JBoss 6/7, etc) which thus supports EL 2.2, then you can just pass it as method argument instead:

<h:panelGrid>
    <f:ajax event="click" listener="{bean.clickFlight(searchResult.index)}" />

    <!-- I get some info here from the searchResult object -->
</h:panelGrid>

您甚至可以通过整个对象,如果preferred:

you can even pass the whole object if preferred:

<h:panelGrid>
    <f:ajax event="click" listener="{bean.clickFlight(searchResult)}" />

    <!-- I get some info here from the searchResult object -->
</h:panelGrid>

这是另一种,如果你需要&LT; F:参数&GT; 本身是使用&LT; H:commandLink&GT; 代替。

An alternative, if you need <f:param> per se, would be to use <h:commandLink> instead.

<h:commandLink>
    <f:ajax event="click" listener="{bean.clickFlight(searchResult)}" />
    <f:param name="lfi" value="#{searchResult.index}" />

    <h:panelGroup>
        <!-- I get some info here from the searchResult object -->
    </h:panelGroup>
</h:commandLink>

这篇关于使H:panelGroup中点击,并发送回反复变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆