में फ़ोरैच लूप का उपयोग करके मुझे अपने पृष्ठ पर कमांडबूटन की एक सूची बनाने की आवश्यकता है, लेकिन मुझे इसके साथ कुछ परेशानी है। मैं request.setAttribute के माध्यम से अपनी बीन से सूची पास करता हूं और ऐसा लगता है कि जब मैं एक समय में मूल्य प्राप्त करता हूं, लेकिन जब मैं फ़ोरैच लूप के माध्यम से चलता हूं, तो वे सभी शून्य होते हैं (और इस तरह उत्पन्न होते हैं, और एक होने डिफ़ॉल्ट मान 0, "" आदि, जहां तक मुझे पता है)। किसी भी तरह की सहायता का स्वागत किया जाएगा! अतिरिक्त कोड में, जब मैं फ़ोरैच लूप के बाहर बटन बनाता हूं, तो मुझे सही मान मिलते हैं, लेकिन जब मैं लूप चलाता हूं तो नहीं। सूची पूर्णांक प्रकार का है, और बाद में जावा वस्तु होनी चाहिए (एक ही समस्या में भाग गया)। जेएसएफ संस्करण 2.2 का उपयोग कर। दोनों logtest() और gotoprofile() रुचि सूचक बाहर प्रिंट करता है।जेएसएफ
मेरी सेम है:
@ManagedBean(name="MyProfile")
@RequestScoped
और मैं के साथ मेरी सेम में मेरी चर 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}" action="#{MyProfile.logTest}">
<f:setPropertyActionListener target ="#{MyProfile.interestPointer}" value = "#{orly}"/>
</h:commandButton><p>
</ui:repeat>
<c:forEach var="orly" items="${MyProfile.interestsAndPointers}" varStatus="status" >
<c:out value="${status.index}"/><c:out value=": "/><c:out value="${orly.stringName}"/><h:commandButton value="go to interest page" action="#{MyProfile.goToInterestProfile}">
<f:setPropertyActionListener target ="#{MyProfile.interestPointer}" value = "#{orly.pointer}"/>
</h:commandButton><p>
</c:forEach>
</h:form>
</body>
</f:view>
</html>
उपयोग $ {Orly} # के बजाय {Orly} –
मैं इस त्रुटि मिलती है संकलन करने का प्रयास करेगा। "टीएलडी के मुताबिक, विशेषता मान एक डिफर्ड-वैल्यू या डिफर्डर्ड-विधि है, लेकिन निर्दिष्ट मान में $ -expression" – user3058296