我需要在我的页面上创建一个命令按钮列表,但是我遇到了一些问题.我通过request.setAttribute从我的bean传递列表,它似乎在我一次获取一个值时工作,但是当我运行foreach循环时,它们似乎都是null(从而生成,并且具有默认值0,""等,据我所知).任何帮助将不胜感激!在添加的代码中,当我在foreach循环之外创建按钮时,我得到正确的值,但是当我运行循环本身时却没有.List是整数类型,稍后应该是一个java对象(遇到同样的问题).使用JSF 2.2版.logtest()和gotoprofile()都打印出兴趣指针.
我的豆子有:
@ManagedBean(name="MyProfile")
@RequestScoped
Run Code Online (Sandbox Code Playgroud)
我在我的bean中设置我的变量myInterestList:
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
session.setAttribute("myInterestProfileName", profileName);
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ page import="java.util.List,com.jsflogin.stringWithPointer" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<f:view>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSF Successfull login</title>
</head>
<body>
<h:form id="forloop">
<c:set var ="myTempList" value="${myInterestListYay}" scope="session"/>
<c:out value="interest list"/><p>
<h:commandButton value="#{myInterestListYay[1]}" action="#{MyProfile.logTest}">
<f:setPropertyActionListener target ="#{MyProfile.interestPointer}" value = "#{myInterestListYay[1]}"/>
</h:commandButton><p>
<ui:repeat var="orly"value="${myInterestListYay}" varstatus="status">
<c:out value="${status.index}"/><h:commandButton value="#{orly}" …Run Code Online (Sandbox Code Playgroud)