JSF - Methode kann nicht aufgerufen werden

  • Themenstarter Themenstarter HeMa86
  • Beginndatum Beginndatum
H

HeMa86

Gast
Hallo

Ich versuche vergeblich über eine ManagedBean (artikel) eine Methode (addBohr1) aufzurufen. Zwar kennt die Bean die Methode, aber sie greift nicht darauf zu.
Außerdem greift diese Bean auf der Selben Seite auf eine andere Methode erfolgreich zu.

Hier der JSF-Code
Java:
<h:panelGrid>
	<h:outputLabel for="bohr1" value="Test"></h:outputLabel>
	<h:graphicImage id="bohr1" url="images/Bohrer/bohr1.jpg" style="height: 160px; width: 170px" />
								
	<h:commandButton value="Test" action="#{account.addBohr1}"/>

</h:panelGrid>

.. und die aufzurufende Methode:

Java:
	public String addBohr1() {
		System.out.println("TEST");
		return "access";
	}

hat jemand eine Ahnung an was das liegen könnte?

Danke schon mal im Voraus!
 
Entschuldigung für die späte Antwort..

Hier mal ein paar mehr Details:

Wie gesagt der commandButton für den login funktioniert noch, jedoch die anderen 2 nicht mehr. Die auzurufende Methode in der Bean kennt ihr ja bereits.

Die komplette JSF-Seite:
Java:
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Startseite</title>
</head>
<body>
<f:view>
	<h:form style="margin: 80 px;">

		<h:panelGrid columns="3" border="1"
			style="width: 1000px; border-left-color: Blue; border-top-color: Blue; border-right-color: Blue; border-bottom-color: Blue; border-bottom-width: thin; border-right-width: thin; border-left-width: thin; border-top-width: thin">

			<%-- Oben - Linkes (1|1) (Überschrift) --%>
			<h:graphicImage id="header_logo" url="images/werkzeug.jpg"
				style="height: 164px; width: 178px" />

			<%-- Oben - Mitte- Rechts (1|2) (Überschrift) --%>
			<f:verbatim>
				<h1 align="center">Raphael's Werkzeugladen</h1>
			</f:verbatim>

			<%-- Oben - Rechts (1|3) (Login) --%>
			<h:panelGroup>
				<h:panelGrid columns="2" styleClass="borderTable"
					headerClass="panelHeading" style="width: 156px; height: 149px">
					<f:facet name="header">
						<h:outputText value="Anmeldung zum WebShop"
							style="background-color: #0000A0; color: White" />
					</f:facet>
					<h:outputLabel for="Kundennummer" value="Loginname:" />
					<h:inputText id="Kundennummer" value="#{account.name}"
						required="true" style="width: 126px" />
					<h:outputLabel for="Passwort" value="Passwort:" />
					<h:inputSecret id="Passwort" value="#{account.pass}"
						required="true" style="width: 125px" />
					<h:commandButton action="#{account.login}" value="Anmelden"
						style="color: #FFFFFF; background-color: #0000A0" />
					<h:outputText value="#{account.eingeloggt}"></h:outputText>
				</h:panelGrid>
				<f:verbatim>
					<a href="persoenlicheDaten.jsf">Registrieren?</a>
				</f:verbatim>
			</h:panelGroup>

			<%-- Unten - Links (2|1) (Navigation) --%>
			<h:panelGroup>
				<h:panelGrid columns="2">
					<h:graphicImage id="side_bar" url="images/bg_blue.png"
						style="height: 400px; width: 18px" />
								<h:panelGrid border="0" columns="1" style="width: 68px; height: 200px; color: #FFFFFF; background-color: White;">	
								<f:verbatim>
										<a href="startseite.jsf">Seite1</a>
								</f:verbatim>	
								<f:verbatim>
										<a href="startm.jsf">Seite2</a>
								</f:verbatim>
								</h:panelGrid>
				</h:panelGrid>
			</h:panelGroup>

			<%-- Unten - Mitte (2|2) (Artikelansicht) --%>
			<h:panelGroup>

				<f:verbatim>
					<h2 align="center" style="height: 43px; width: 666px">Ansicht</h2>
				</f:verbatim>
					
					<h:panelGrid columns="2" style="width: 703px; height: 386px">

						<h:panelGrid>
						<h:outputLabel for="bohr1" value="Test"></h:outputLabel>
						<h:graphicImage id="bohr1" url="images/Saege/test.jpg"
							style="width : 199px; height : 140px;" />
						<h:commandButton action="#{account.addBohr1}" value="TEST" style="color: White; background-color: #0000A0"></h:commandButton>
						</h:panelGrid>


						<h:panelGrid>
						<h:outputLabel for="bohr2" value="Test"></h:outputLabel>
						<h:graphicImage id="bohr2" url="images/Saege/test.jpg"
							style="height: 140px; width : 199px;" />
						<h:commandButton action="#{artikel.addBohr2}" value="TEST" style="color: White; background-color: #0000A0"></h:commandButton>
						</h:panelGrid>
				
					</h:panelGrid>
			</h:panelGroup>

			<%-- Unten - Rechts (2|3) (Warenkorb) --%>
			<h:panelGroup>
				<h:outputText value="Warenkorb" style="color: White; background-color: #0000A0"> 
			           </h:outputText>
			
				<h:panelGrid columns="1" style="width: 180px">
				<h:outputText value="#{artikel.result}"></h:outputText>
				<f:verbatim>
					<a href="checkout.jsf">Weiter zum Checkout</a>
				</f:verbatim>
				</h:panelGrid>
			</h:panelGroup>

		</h:panelGrid>

	</h:form>
</f:view>
</body>
</html>

Hier noch die Konsolen-Ausgabe:


----------------------------------------------------------------------------
05.05.2010 10:20:38 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programme\Java\jre1.6.0_02\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Programme/Java/jre6/bin/client;C:/Programme/Java/jre6/bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\GTK2-Runtime\bin;c:\Programme\Microsoft SQL Server\90\Tools\binn\;C:\Programme\Apache Software Foundation\apache-ant\bin;C:\Programme\Java\jdk1.6.0_02\bin;D:\Set-Ups\apache-maven-2.2.1\bin
05.05.2010 10:20:38 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
05.05.2010 10:20:38 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 394 ms
05.05.2010 10:20:38 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
05.05.2010 10:20:38 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
log4j:WARN No appenders could be found for logger (org.apache.myfaces.webapp.StartupServletContextListener).
log4j:WARN Please initialize the log4j system properly.
05.05.2010 10:20:39 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
05.05.2010 10:20:39 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
05.05.2010 10:20:39 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/31 config=null
05.05.2010 10:20:39 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1245 ms
05.05.2010 10:20:40 org.apache.catalina.core.ApplicationContext log
INFO: No state saving method defined, assuming default server state saving
----------------------------------------------------------------------------

Bin echt am ende meines Lateins, also danke für eure Hilfe!
 
Wie sind denn die Managedbeans #artikel und #account deklariert ?

Wieso einmal:
<h:commandButton action="#{account.addBohr1}"

und dann ..
<h:commandButton action="#{artikel.addBohr2}"

?

Wahrscheinlich gibts in deiner ManagedBean #account keine Methode addBohr1...
 
achso, nein das hab ich nur zu Testzwecken gemacht.. (Immerhin funktioniert der Methodeaufruf .login der account bean noch)

Die Methode ist sowohl in der account und artikel bean enthalten.
 
Nun endlich gelöst!

Das Problem war ohne das ich im Passwortfeld inputsecret nichts geschrieben habe, wurde ich nicht weitergeleitet und der login funktionierte weil ich hierbei natürlich ein Passwort eingegeben habe...
 

Neue Themen


Zurück
Oben