简体   繁体   English

使用JQuery Mobile进行JSF Ajax调用

[英]JSF Ajax Call with JQuery Mobile

This issue has been troubling me to no end!! 这个问题一直困扰着我!

I have seen the forum post JSF f:ajax listener not called which describes my exact issue. 我看过论坛帖子JSF f:ajax监听器未调用 ,它描述了我的确切问题。

I am using JSF 2.0 and am using the Jquery mobile as an extension library. 我正在使用JSF 2.0,并且正在使用Jquery mobile作为扩展库。

I have actually copied the code exactly from the post, into my project (shown below). 实际上,我已经将代码完全从帖子中复制到了我的项目中(如下所示)。

I have the same managed bean set in session scope, printing out a line. 我在会话范围中设置了相同的托管bean,打印了一行。 I can see the bean successfully executing on the first input text the one assigned with an ajax listener 我可以看到bean在第一个输入文本上成功执行了一个用ajax监听器分配的bean

It doesn't however work for the button. 但是,此按钮不适用于该按钮。 In my use case, I want the button only to act as a bridge for calling the managed bean, so don't want the form to submit. 在我的用例中,我希望按钮仅充当调用托管bean的桥梁,所以不希望表单提交。

I am at a complete loss as to why the bean isn't executed? 我完全不知道为什么不执行该bean?

I have no overriding JS classes either, and am using Jquery mobile only. 我也没有重写的JS类,并且仅使用Jquery mobile。

Is this a restriction on the Jquery framework? 这是对Jquery框架的限制吗? or more than likely an issue with my code? 或更多可能是我的代码有问题?

S 小号

<h:form id="f1">
<h:panelGroup id="switchSearchTexts">
    <h:inputText accesskey="s" alt="Search" id="searchBoxPeople" title="Search Plebeians" valueChangeListener="#{peopleBean.simplePersonQuery}" size="25" rendered="#{peopleBean.easySearch}">
        <f:ajax render="peopleDataTable" event="keyup" listener="#{contactsBean.morePressed}"
                immediate="true"/>
    </h:inputText>

    <h:inputText accesskey="s" alt="Search First Name" id="searchBoxFN" title="Search First Name" size="25" rendered="#{!peopleBean.easySearch}">
        <f:ajax render="moreButtonAsText" event="keyup" />
    </h:inputText>
</h:panelGroup>

<div id="expandBox">
    <h:inputText id="searchBoxLN" alt="Search Last Name" styleClass="hideToggle" title="Search Last Name" size="25" />
    <h:inputText id="searchBoxAddress" alt="Search Address" styleClass="hideToggle" title="Search Address" size="25" />
</div>

<h:commandButton type="button" styleClass="moreButtonAsText" id="moreButtonAsText" value="More">
    <f:ajax listener="#{contactsBeanFaces.morePressed}"/>
</h:commandButton>
</h:form>

*** CORRECTION **** ***更正****


my apologies, I was seriously trying everything! 抱歉,我正在认真尝试所有事情! and posted the wrong iteration of code! 并发布了错误的代码迭代!
I have found a great note: http://java.dzone.com/articles/ajax-jsf-joined which has been a huge help, however still no success. 我发现了一个很好的注释: http : //java.dzone.com/articles/ajax-jsf-joined ,它提供了巨大的帮助,但是仍然没有成功。 I am feeling jquery mobile is messing with the event? 我感觉jquery mobile搞砸了活动吗?

I believe that there may also be a requirement for the button to be in a form? 我认为可能还需要按钮采用某种形式?

Sorry abou the basic questions, however i am a Jdeveloper guy, who is kind of learning backwards.... the DOM and client java / html side of things is almost unfairly hidden with this application. 抱歉,基本问题仍然存在,但是我是一个Jdeveloper家伙,他在向后学习。...DOM和客户端Java / html方面的东西在此应用程序中几乎被不公平地隐藏了。 I am loving client side libraries and learning whole lot through this process.... but a strong requirement is that I can call server side logic! 我喜欢客户端库,并在此过程中学习了很多东西。...但是一个很重要的要求是我可以调用服务器端逻辑!

Any ideas would be very much appreciated! 任何想法将不胜感激!

Ok solved. 好了,解决了。

The issue is that the managed bean needs to be set up with the right signature event as an input param. 问题在于,需要使用正确的签名事件作为输入参数来设置托管bean。 Through lots of testing, I was trying to use the same class taking an AjaxBehaviorEvent. 通过大量测试,我试图使用带有AjaxBehaviorEvent的同一类。 As in the same example on the previous forum. 与之前论坛中的相同示例相同。

when I declared an ActionListener event (compliant with the button jsf action), the bean is executed! 当我声明一个ActionListener事件(与按钮jsf操作兼容)时,该bean被执行!

Stoked, and shows what fresh eyes can bring! 勾勒出自己的眼睛,并显示出新鲜的眼睛可以带来什么!

Thanks Daniel! 谢谢丹尼尔!

S 小号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM