Foros del Web » Programación para mayores de 30 ;) » Java »

JavaServer Faces + JavaStandardTagLibrary

Estas en el tema de JavaServer Faces + JavaStandardTagLibrary en el foro de Java en Foros del Web. Hola, buenas, espero me puedan ayudar, necesito crear tres botones en Jsf, tengo una clase de botones que segun la pagina donde este en ese ...
  #1 (permalink)  
Antiguo 05/10/2006, 14:41
 
Fecha de Ingreso: mayo-2004
Ubicación: Managua, Nicaragua
Mensajes: 281
Antigüedad: 20 años
Puntos: 0
JavaServer Faces + JavaStandardTagLibrary

Hola, buenas, espero me puedan ayudar, necesito crear tres botones en Jsf, tengo una clase de botones que segun la pagina donde este en ese momento crea los botones ya sea: 1)Guardar,Limpiar,Cancelar 2)Buscar,Limpiar,Cancelar, etc.

La cosa es que para crearlos utilizo los JSTL y JSF combinados como sigue:

Código:
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="x"%>

<jsp:useBean id="btn" class="pkgfarma_net.admin.modelo.botones" scope="page"/>

<f:view>
  <c:choose>
    <c:when test="${param['accion'] == 'agregar'}">
      <c:forEach var="valor" items="${btn.agregar}">
        <tr>
          <td><h:commandButton id="btnPrueba"></h:commandButton></td>
        </tr>
      </c:forEach>
    </c:when>
    <c:otherwise>
      <c:forEach var="valor" items="${btn.buscar}">
          <h:commandButton id="btnPg" value="#{param['valor']}" type="submit" />
      </c:forEach>
    </c:otherwise>
  </c:choose>
</f:view>
La preguna es, como puedo poner la variable "valor" dentro del value del CommandButton, como puedo utilizar una variable de jstl en jsf?. Alguna sugerencia.

Saludos !.
__________________
Julio Hernández
  #2 (permalink)  
Antiguo 08/10/2006, 15:48
 
Fecha de Ingreso: mayo-2004
Ubicación: Managua, Nicaragua
Mensajes: 281
Antigüedad: 20 años
Puntos: 0
Ya he resuelto mi problema, realmente no es utilizar las variables de Jstl en Jsf, sino que estos trabajan con las objetos implicitas descritas en el tutorial de J2EE. Pongo algunas que se describen en ese manual:

Código:
Implicit Objects
The JSP expression language defines a set of implicit objects:
• pageContext: The context for the JSP page. Provides access to various
objects including:
• servletContext: The context for the JSP page’s servlet and any web
components contained in the same application. See Accessing the Web
Context (page 473).
• session: The session object for the client. See Maintaining Client
State (page 474).
• request: The request triggering the execution of the JSP page. See Getting
Information from Requests (page 458).
• response: The response returned by the JSP page. See Constructing
Responses (page 460).
EXPRESSION LANGUAGE 503
In addition, several implicit objects are available that allow easy access to the
following objects:
• param: Maps a request parameter name to a single value
• paramValues: Maps a request parameter name to an array of values
• header: Maps a request header name to a single value
• headerValues: Maps a request header name to an array of values
• cookie: Maps a cookie name to a single cookie
• initParam:Maps a context initialization parameter name to a single value
Finally, there are objects that allow access to the various scoped variables
described in Using Scope Objects (page 453).
• pageScope: Maps page-scoped variable names to their values
• requestScope: Maps request-scoped variable names to their values
• sessionScope: Maps session-scoped variable names to their values
• applicationScope: Maps application-scoped variable names to their values
Lo he resuelto de la siguiente manera, el alcande del bean lo declare como request, ademas tuve que declarar la variable con el Jstl <c:set con alcance tambien request. Muestro el codigo a continuacion:

Código:
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="x"%>

<jsp:useBean id="btn" class="pkgfarma_net.admin.modelo.botones" scope="request"/>

<f:view>
  <c:choose>
    <c:when test="${param['accion'] == 'agregar'}">
      <c:forEach var="Tit" items="${btn.agregar}">
        <c:set var="Tit" value="${Tit}" scope="request" />
        <h:commandButton id="botones" value="#{requestScope.Tit[0]}" styleClass="bordes"/>
      </c:forEach>
    </c:when>
    <c:otherwise>
          <h:commandButton id="btnBuscar" value="Buscar" styleClass="bordes"/><h:commandButton id="btnLimpiar" value="Limpiar" type="button" styleClass="bordes"/><h:commandButton id="btnCancelar" value="Cancelar" type="button" styleClass="bordes"/>
    </c:otherwise>
  </c:choose>
</f:view>
__________________
Julio Hernández
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 15:44.