V.Rohan
V.Rohan

Reputation: 945

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_

<%@ 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.

then what can i do for this,how i can use javascript? and i have less knowledge of JS. Thanx

Upvotes: 2

Views: 4597

Answers (1)

BalusC
BalusC

Reputation: 1109532

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).

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. There was no other decent Ajax library for JSF. I vaguely recall some library on top of Dojo as ripoff of this IBM article, but it was impopular. Later, during the beginning of the JSF 1.2 era, Ajax4jsf was acquired by JBoss RichFaces and included as its sublibrary. Since then, you can't download Ajax4jsf separately from an official site anymore, you'd have to download the whole RichFaces component library along.

However, somewhere deep in a Maven archive, you can still download the original Ajax4jsf library. Here it is: Ajax4jsf 1.0.6. The original java.net site is down, so the original developer guide is not available anymore either. 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). Further there's also a JavaWorld article on how to setup and use it (in combination with MyFaces).

Ultimately, you'd like to end up using <a4j:support> something like as:

<%@ 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>

Upvotes: 6

Related Questions