Buenos dias Angel, ojala puedas ayudarme!
/*
* YellProxy.java
*
* Created on 13 de septiembre de 2007, 11:59
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package es.yell.frontlite.servlets;
import java.util.Collection;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent ;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import org.springframework.beans.factory.InitializingBean;
import es.yell.frontlite.service.impl.*;
import org.springframework.util.Assert ;
/**
* Esta clase va a hacer las siguientes acciones:
* Averiguar quien es el cliente, IE, firefox, PDA.
* Averiguar si tiene el js activado.
* en funcion si tiene el js activado o no, redirijo la peticion a un
servicio u otro
* la peticion que hace el cliente
* @author operador
*/
public class YellProxy{
//campo que sirve para almacenar el resultado de la operacion que se
hace en el cliente para ver si js esta activado.
private String jsActivado;
//campo que representa la identidad del navegador, IE, firefox...
private String quienSoy;
//campos que van a almacenar los campos que y donde de la pagina ppal.
private String campoQue;
//a este campo habra que destokenizar para rellenar los siguientes
campos, direccion, localidad y cp
private String campoDonde;
//atributo que pasamos al servicio con los parametros que nos da el
formulario de la jsp
private BusquedaVO busquedaVO;
//el servicio que nos da acceso a la capa de datos.INYECTADO
private SrvBusquedaNoxtrumServiceImpl servicio;
//atributo q contiene toda la informacion cuando utilizamos AJAX
private String xml;
//atributo q contiene toda la informacion cuando no utilizamos AJAX
private Collection coleccion;
/** Creates a new instance of YellProxy */
public YellProxy() {
}
/**
*Este metodo responde al evento del boton encuentra que esta en la
pagina principal.
*Basicamente va a destokenizar el campo campoDonde en los subcampos
Direccion, localidad y CP.
*Tambien y dependiendo de si el cliente tiene activado o no el js,
ejecutaremos un servicio u otro.
*/
public String encuentra(){
//deja los atributos privados rellenos.
String mensaje ;
crearYRellenarBusquedaVO();
//Javscript activado
if (getJsActivado()!=null &&
getJsActivado().compareToIgnoreCase("S") == 0){
//invocamos servicio adecuado
setXml(this.getServicio().obtenerResultadosJSactivado(
this.getBusquedaVO ()));
mensaje="succesJS";
}else{
//javascript no activado
this.setColeccion(this.getServicio
().obtenerResultadosJSdesactivado(this.getBusquedaVO ()));
mensaje="succesNoJS";
}
return mensaje;
}
private void crearYRellenarBusquedaVO() {
if (busquedaVO == null){
busquedaVO = new BusquedaVO();
}
busquedaVO.setCampoQue(this.getCampoQue());
busquedaVO.setCampoDonde(this.getCampoDonde());
}
public String getCampoQue() {
return campoQue;
}
public void setCampoQue(String campoQue) {
this.campoQue = campoQue;
}
public String getCampoDonde() {
return campoDonde;
}
public void setCampoDonde(String campoDonde) {
this.campoDonde = campoDonde;
}
public String getJsActivado() {
return jsActivado;
}
public void setJsActivado(String jsActivado) {
this.jsActivado = jsActivado;
}
public String getQuienSoy() {
return quienSoy;
}
public void setQuienSoy(String quienSoy) {
this.quienSoy = quienSoy;
}
public BusquedaVO getBusquedaVO() {
return busquedaVO;
}
public void setBusquedaVO(BusquedaVO busquedaVO) {
this.busquedaVO = busquedaVO;
}
public String getXml() {
return xml;
}
public void setXml(String xml) {
this.xml = xml;
}
public Collection getColeccion() {
return coleccion;
}
public void setColeccion(Collection coleccion) {
this.coleccion = coleccion;
}
public SrvBusquedaNoxtrumServiceImpl getServicio() {
return servicio;
}
public void setServicio(SrvBusquedaNoxtrumServiceImpl servicio) {
this.servicio = servicio;
}
}
2007/9/24, Angel Miralles Arevalo < [EMAIL PROTECTED]>:
>
> Please, send your bean code #{yellProxy.encuentra}.
>
> ----- Mensaje original ----
> De: Alonso Isidoro Roman < [EMAIL PROTECTED]>
> Para: [email protected]
> Enviado: lunes, 24 de septiembre, 2007 12:08:21
> Asunto: pls help with exception
>
> hi everybody, i`m newbee with jsf first at all!
>
>
> it takes me this exception when i submit the form:
>
> javax.servlet.ServletException
> : Error calling action method of component with id formulario:boton
> javax.faces.webapp.FacesServlet.service
> (FacesServlet.java:152)
>
> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java
> :368)
>
> *causa raíz*
>
> javax.faces.FacesException: Error calling action method of component with id
> formulario:boton
>
>
> org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
>
>
> de.mindmatters.faces.application.DelegatingActionListener.processAction(DelegatingActionListener.java:106)
> javax.faces.component.UICommand.broadcast
> (UICommand.java:106)
> org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents
> (AjaxViewRoot.java:274)
>
> org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:250)
> org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication
> (AjaxViewRoot.java:405)
> de.mindmatters.faces.lifecycle.InvokeApplicationPhase.executePhase
> (InvokeApplicationPhase.java:43)
>
> de.mindmatters.faces.lifecycle.AbstractPhase.execute(AbstractPhase.java:37)
> de.mindmatters.faces.lifecycle.LifecycleImpl.executePhase
> (LifecycleImpl.java:166)
> de.mindmatters.faces.lifecycle.LifecycleImpl.execute
> (LifecycleImpl.java:211)
> javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter
> (MonitorFilter.java:368)
>
>
>
> my faces page is
>
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
> <%@ taglib uri=" http://java.sun.com/jsf/core" prefix="f" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> <html>
> <f:view>
> <f:loadBundle basename="MessageResources" var="msg"/>
> <head>
> <title>
> ${msg.titulo}
> </title>
> </head>
>
> <body>
> <h:form id="formulario">
> <h:inputText id="campoQue" value="#{ yellProxy.campoQue}" />
> <h:inputText id="campoDonde" value="#{yellProxy.campoDonde }" />
> <h:commandButton id="boton" value="#{msg.boton}" action="#{
> yellProxy.encuentra }"/>
> </h:form>
> </f:view>
> </body>
> </html>
>
> my faces-config is:
>
> <?xml version='1.0' encoding='UTF-8'?>
>
>
> <!DOCTYPE faces-config PUBLIC
> "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
> " http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
>
> <!-- =========== FULL CONFIGURATION FILE
> ================================== -->
>
> <faces-config>
> <!-- El mantenimiento del bean proxy se delega al contenedor de
> spring-->
>
> <application>
> <variable-resolver>
> org.springframework.web.jsf.DelegatingVariableResolver
> </variable-resolver>
> </application>
>
> <!-- el unico idioma permitido es el español.-->
> <application>
> <locale-config>
> <default-locale>es</default-locale>
> </locale-config>
> </application>
>
> <!--
> - navigation rules
> -->
> <navigation-rule>
> <from-view-id>/index.jsp</from-view-id>
> <navigation-case>
> <from-outcome>succesJS</from-outcome>
> <to-view-id>/jsActivado.jsp</to-view-id>
> </navigation-case>
> <navigation-case>
> <from-outcome>succesNoJS</from-outcome>
> <to-view-id>/jsDesactivado.jsp</to-view-id>
> </navigation-case>
> </navigation-rule>
> </faces-config>
>
> my applicationContext.xml is
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
> " http://www.springframework.org/dtd/spring-beans-2.0.dtd ">
> <beans>
>
> <bean id="ParserSAX" class="
> es.yell.frontlite.parser.ParserPrincipalHandler" scope="singleton"/>
>
> <bean id="Controller" class=" es.yell.frontlite.servlets.Controller"
> scope="singleton"/>
>
> <bean id="srvBusquedaNoxtrumService" class="
> es.yell.frontlite.service.impl.SrvBusquedaNoxtrumServiceImpl "
> scope="singleton">
> <property name="parserSAX"><ref bean="ParserSAX"/></property>
> <property name="controlador"><ref bean="Controller"/></property>
> </bean>
>
> <bean id="yellProxy" class="es.yell.frontlite.servlets.YellProxy"
> scope="singleton">
> <property name="servicio">
> <ref bean="srvBusquedaNoxtrumService"/>
> </property>
> </bean>
> </beans>
>
> another question:
>
> why do i have to put the url http: // localhost:8084/index.faces i browser
> instead of
> Http: // localhost:8084/index.jsp
> Or
> Http: // localhost:8084/index.jsf?
>
> pls help
> --
> Alonso Isidoro Roman.
>
>
> ------------------------------
>
> Sé un Mejor Amante del Cine
> ¿Quieres saber cómo? ¡Deja que otras personas te ayuden!
> <http://us.rd.yahoo.com/mail/es/tagline/beabetter/*http://advision.webevents.yahoo.com/reto/entretenimiento.html>
> .
>
--
Alonso Isidoro Roman.