前提・実現したいこと
名簿作成で番号と氏名をmeidoクラスに渡したい
meido.numberに番号
meido.nameに氏名を代入したい。
発生している問題・エラーメッセージ
An Error Occurred: /index.xhtml @11,58 value="#{meiboBean.numer}": Target Unreachable, identifier 'meiboBean' resolved to null
該当のソースコード
xhtml
1<?xml version='1.0' encoding='UTF-8' ?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml" 4 xmlns:h="http://xmlns.jcp.org/jsf/html"> 5 <h:head> 6 <title>Sample01</title> 7 </h:head> 8 <h:body> 9 <h2>名簿データの作成</h2> 10 <h:form> 11 番号:<h:inputText value="#{meiboBean.numer}" /><hr/> 12 氏名:<h:inputText value="#{meiboBean.name()}" /><hr/> 13 <h:commandButton value="送信" actionListener="#{meiboBean.toConsole()}" /> 14 </h:form> 15 </h:body> 16</html>
java
1/* 2 * To change this license header, choose License Headers in Project Properties. 3 * To change this template file, choose Tools | Templates 4 * and open the template in the editor. 5 */ 6package beans; 7import javax.enterprise.context.RequestScoped; 8import javax.inject.Named; 9@Named("myBean") 10@RequestScoped 11/** 12 * 13 * @author user 14 */ 15public class MeiboBean { 16 private Integer number; 17 private String name; 18 19 public void toConsole() { 20 System.out.println("number="+this.number+"/ name=" + this.name ); 21 } 22 23 public Integer getNumber() { 24 return number; 25 } 26 27 public void setNumber(Integer number) { 28 this.number = number; 29 } 30 31 public String getName() { 32 return name; 33 } 34 35 public void setName(String name) { 36 this.name = name; 37 } 38} 39
試したこと
xhtmlのvalue="#{meiboBean.numer}" を
meidoBean.setNumber, meiboBean.setNumber()にしてみた
補足情報(FW/ツールのバージョンなど)
JDK 1.8
GlassFish
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/27 04:47