This content has been marked as final.
Show 3 replies
-
1. Re: MyFaces, Facelets and Ajax4JSF
sergeysmirnov Aug 29, 2007 7:34 PM (in response to thiagodfreitas)As usual... could you provide the page code snippet, please.
-
2. Re: MyFaces, Facelets and Ajax4JSF
thiagodfreitas Aug 29, 2007 7:37 PM (in response to thiagodfreitas)here is my code:
index.xhtml :<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:h="http://java.sun.com/jsf/html"> <f:view> <a4j:page> <h:form> <h:inputText value="#{teste.teste}"> <a4j:support event="onkeyup" reRender="texto" rendered="true"></a4j:support> </h:inputText> <h:outputText value="#{teste.teste}" id="texto" rendered="true"></h:outputText> </h:form> </a4j:page> </f:view> </html>
Teste.java -> my backing beanpublic class Teste { private String teste = "teste"; public String getTeste() { System.out.println("buscando valor: " + teste); return teste; } public void setTeste(String teste) { System.out.println("Setando valor: " + teste); this.teste = teste; } }
FacesConfig.xml<?xml version="1.0"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"> <faces-config> <managed-bean> <managed-bean-name>teste</managed-bean-name> <managed-bean-class>Teste</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> <application> <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> </application> </faces-config>
Web.xml<?xml version="1.0"?> <!-- * Copyright 2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. --> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>coisa1</display-name> <context-param> <description>State saving method: "client" or "server" (= default) See JSF Specification 2.5.2</description> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <context-param> <description>This parameter tells MyFaces if javascript code should be allowed in the rendered HTML output. If javascript is allowed, command_link anchors will have javascript code that submits the corresponding form. If javascript is not allowed, the state saving info and nested parameters will be added as url parameters. Default: "true"</description> <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name> <param-value>true</param-value> </context-param> <context-param> <description>This parameter tells MyFaces if javascript code should be allowed in the rendered HTML output. If javascript is allowed, command_link anchors will have javascript code that submits the corresponding form. If javascript is not allowed, the state saving info and nested parameters will be added as url parameters. Default: "false" Setting this param to true should be combined with STATE_SAVING_METHOD "server" for best results. This is an EXPERIMENTAL feature. You also have to enable the detector filter/filter mapping below to get JavaScript detection working.</description> <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name> <param-value>false</param-value> </context-param> <context-param> <description>If true, rendered HTML code will be formatted, so that it is "human readable". i.e. additional line separators and whitespace will be written, that do not influence the HTML code. Default: "true"</description> <param-name>org.apache.myfaces.PRETTY_HTML</param-name> <param-value>true</param-value> </context-param> <context-param> <description>If true, a javascript function will be rendered that is able to restore the former vertical scroll on every request. Convenient feature if you have pages with long lists and you do not want the browser page to always jump to the top if you trigger a link or button action that stays on the same page. Default: "false"</description> <param-name>org.apache.myfaces.AUTO_SCROLL</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <context-param> <param-name>facelets.REFRESH_PERIOD</param-name> <param-value>2</param-value> </context-param> <!-- WelcomeFile Filter <filter> <filter-name>WelcomeFile Filter</filter-name> <filter-class>org.apache.myfaces.webapp.filter.WelcomeFileFilter</filter-class> <description> Due to the manner in which the JSP / servlet lifecycle functions, it is not currently possible to specify default welcome files for a web application and map them to the MyFacesServlet. Normally they will be mapped to the default servlet for the JSP container. To offset this shortcoming, we utilize a servlet Filter which examines the URI of all incoming requests. </description> </filter> JavaScriptDetector Filter <filter> <filter-name>javascriptDetector</filter-name> <filter-class>org.apache.myfaces.webapp.filter.JavaScriptDetectorFilter</filter-class> </filter> Extensions Filter --> <filter> <filter-name>extensionsFilter</filter-name> <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class> <init-param> <description>Set the size limit for uploaded files. Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB</description> <param-name>uploadMaxFileSize</param-name> <param-value>100m</param-value> </init-param> <init-param> <description>Set the threshold size - files below this limit are stored in memory, files above this limit are stored on disk. Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB</description> <param-name>uploadThresholdSize</param-name> <param-value>100k</param-value> </init-param> <!-- <init-param> <param-name>uploadRepositoryPath</param-name> <param-value>/temp</param-value> <description>Set the path where the intermediary files will be stored. </description> </init-param>--> </filter> <filter> <display-name>Ajax4jsf Filter</display-name> <filter-name>ajax4jsf</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <!-- Filter Mappings see MyFaces Filter above for a description <filter-mapping> <filter-name>WelcomeFile Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>javascriptDetector</filter-name> <url-pattern>/_javascriptDetector_</url-pattern> </filter-mapping>--> <filter-mapping> <filter-name>extensionsFilter</filter-name> <url-pattern>*.jsf</url-pattern> </filter-mapping> <filter-mapping> <filter-name>extensionsFilter</filter-name> <url-pattern>/faces/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>ajax4jsf</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Listener, that does all the startup work (configuration, init). --> <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener> <!-- Faces Servlet --> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Faces Servlet Mapping virtual path mapping <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> extension mapping --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <login-config> <auth-method>BASIC</auth-method> </login-config> </web-app>
-
3. Re: MyFaces, Facelets and Ajax4JSF
thiagodfreitas Aug 29, 2007 8:03 PM (in response to thiagodfreitas)I resolved the problem!
Just changing the ajax4jsf version
:P
Thanks!