Я пытаюсь добавить простой пример selectManycheckbox, но значения не привязываются к компоненту. Я получаюзначения не привязываются к массиву String из h: selectManyCheckbox
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=form1:subscriptions[severity=(ERROR 2), summary=(Conversion Error setting value 'asis base appl' for '#{HomePage.outputType}'.), detail=(Conversion Error setting value 'asis base appl' for '#{HomePage.outputType}'.)]
Это моя страница JSF
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="css/style.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Downloader</title>
</head>
<body>
<f:view>
<h:form id="form1">
<h:panelGrid border="1" columns="2"
style='color: black; font-size: 16px; font-family: "Times New Roman", Serif; font-weight: bold'>
<h:outputLabel value="Select values"></h:outputLabel>
<h:selectManyCheckbox id="subscriptions" value="#{HomePage.outputType}" layout="pageDirection">
<f:selectItem id="item1" itemLabel="ASIS" itemValue="asis"/>
<f:selectItem id="item3" itemLabel="BASE" itemValue="base"/>
<f:selectItem id="item7" itemLabel="APPLIED" itemValue="appl"/>
</h:selectManyCheckbox>
</h:panelGrid>
<h:commandButton type="submit" action="#{HomePage.genOutput}" value="Submit"></h:commandButton>
</h:form>
</f:view>
</body>
</html>
Это мой класс боб HomePage.java:
package com.MH;
import com.MH.WebPageSaver;
public class HomePage{
private String[] outputType;
/*various getter setters*/
public String genOutput() throws Exception{
if (outputType != null)
{
System.out.println("if");
WebPageSaver w = new WebPageSaver();
try{
System.out.println("inside try");
/*independent function below works fine*/
String msg = w.generateOutput(outputType);
return msg;
}
catch (Exception e){
System.out.println(e);
return "error";
}
}
else
{
System.out.println(outputType);
System.out.println("else");
return "error";
}
}
}
Правило нав является одной и той же странице, независимо от сообщ ,
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
<managed-bean>
<managed-bean-name>HomePage</managed-bean-name>
<managed-bean-class>com.MH.HomePage</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/HomePage.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/HomePage.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/HomePage.jsp</from-view-id>
<navigation-case>
<from-outcome>error</from-outcome>
<to-view-id>/HomePage.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Просьба сообщить мне, что мне не хватает здесь?
OP используется JSF 1.2. Ваш ответ предполагает JSF 2.0. Повторите попытку JSF 1.2 и откройте ад. – BalusC
@BalusC lol, все правый. – Andy
ok Энди, Предположим, что код работает, и я пытаюсь показать, какие когда-либо отмечены флажки на странице jsp. То, что сказал Лестер, верно. но всезначения не находятся в jsf1.2. Что еще может быть решением? Надеюсь, ты не смущаешься. – satsamsk