简体   繁体   English

使用Jsf 1.1实现的Ajax

[英]Ajax with Jsf 1.1 implementation

I am using JSF1.1 in that, I want to update 2nd selectOneMenu from 1st one & have this code_ 我正在使用JSF1.1,我想从第1个更新第2个selectOneMenu并使用此code_

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://www.azureworlds.org" prefix="azure"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="x"%>
<%@ taglib uri="http://www.asifqamar.com/jsf/asif" prefix="a"%>

... ...

<h:outputText value="State* " />
<x:selectOneMenu value="#{hotelBean.state}">
                    <f:selectItem itemLabel="Select One" itemValue="" />
                    <f:selectItem value="#{hotelBean.mapStates }" />
                    <x:ajax update="city" listener="#{hotelBean.handleCityChange}" />

</x:selectOneMenu>

                <h:outputText value="City* " />
                <x:selectOneMenu id="city" value="#{hotelBean.city}">

                    <f:selectItem itemLabel="Select One" itemValue="" />

                    <f:selectItem value="#{hotelBean.mapCities }" />
                </x:selectOneMenu>

line x:ajax update="city" listener="#{hotelBean.handleCityChange}" is not working , i searched but got JSF1.1 not support for Ajax. x:ajax update =“ city” listener =“#{hotelBean.handleCityChange}”不起作用,我进行了搜索,但得到了JSF1.1不支持Ajax的信息。

then what can i do for this,how i can use javascript? 那我该怎么办,我该如何使用JavaScript? and i have less knowledge of JS. 而且我对JS的了解较少。 Thanx 感谢名单

According to the Tomahawk 1.1 tag documentation , there is no <t:ajax> tag at all (yes, I know that you renamed t prefix to x for some unclear reason, I'll keep calling it t for consistency). 根据Tomahawk 1.1标记文档 ,根本没有<t:ajax>标记(是的,我知道您出于某些不清楚的原因将t前缀重命名为x为了保持一致性,我将其称为t )。

Previously, during the JSF 1.1 ages, one would have used Ajax4jsf taglib for this which was then still a separate project available at http://ajax4jsf.dev.java.net . 以前,在JSF 1.1时代,人们会为此使用Ajax4jsf taglib,而该标签库仍然是一个单独的项目,可从http://ajax4jsf.dev.java.net获得 There was no other decent Ajax library for JSF. 对于JSF,没有其他像样的Ajax库。 I vaguely recall some library on top of Dojo as ripoff of this IBM article , but it was impopular. 我模糊地回忆起Dojo之上的一些库是这篇IBM文章的翻版,但它并不受欢迎。 Later, during the beginning of the JSF 1.2 era, Ajax4jsf was acquired by JBoss RichFaces and included as its sublibrary. 后来,在JSF 1.2时代初期,Ajax4jsf被JBoss RichFaces收购,并作为其子库包含在内。 Since then, you can't download Ajax4jsf separately from an official site anymore, you'd have to download the whole RichFaces component library along. 从那时起,您不能再从官方站点单独下载Ajax4jsf,而必须一起下载整个RichFaces组件库。

However, somewhere deep in a Maven archive, you can still download the original Ajax4jsf library. 但是,在Maven档案的深处,您仍然可以下载原始的Ajax4jsf库。 Here it is: Ajax4jsf 1.0.6 . 它是: Ajax4jsf 1.0.6 The original java.net site is down, so the original developer guide is not available anymore either. 原始的java.net站点已关闭,因此原始的开发人员指南也不再可用。 However, Google shows that there's a site which has an online backup of the original Ajax4jsf developer guide (the site is very slow; once finished downloading, I'd create an offline copy for faster reference and also for the case it ever goes down). 但是, Google展示了一个站点,该站点具有原始Ajax4jsf开发人员指南在线备份 (该站点非常慢;下载完成后,我将创建一个脱机副本以供快速参考,以及一旦出现故障的情况) 。 Further there's also a JavaWorld article on how to setup and use it (in combination with MyFaces). 此外,还有关于如何设置和使用JavaWorld的JavaWorld文章 (与MyFaces结合使用)。

Ultimately, you'd like to end up using <a4j:support> something like as: 最终,您希望最终使用<a4j:support>东西:

<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
...
<h:outputLabel for="state" value="State* " />
<t:selectOneMenu id="state" value="#{hotelBean.state}">
    <f:selectItem itemLabel="Select One" itemValue="" />
    <f:selectItem value="#{hotelBean.mapStates }" />
    <a4j:support event="onchange" actionListener="#{hotelBean.handleCityChange}" reRender="city" />
</t:selectOneMenu>
<h:outputLabel for="city" value="City* " />
<t:selectOneMenu id="city" value="#{hotelBean.city}">
    <f:selectItem itemLabel="Select One" itemValue="" />
    <f:selectItem value="#{hotelBean.mapCities }" />
</t:selectOneMenu>

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

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