I got a question:
I got a TabPane, designed in a FXML file now i want to change the name of the selected Tab,when a 'check' button is clicked.
public void onAddDateRequest(){
try {
//datePane wird in den FXML Loader geladen
FXMLLoader loader = new FXMLLoader(getClass().getResource("/homenizer/view/datePane.fxml"));
Parent content = (Parent)loader.load();
Tab tab = new Tab("Neuer Termin");
tab.setContent(content); //Dem neuen Tab wird das Layout der FXXML Datei aus Content zugewiesen
tabPane.getTabs().add(tab);
} catch (IOException ex) {
Logger.getLogger(HomenizerController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void onCheckRequest(){
Date date = new Date();
tabPane.getSelectionModel().getSelectedItem().setText("A");
}
The 'onAddDateRequest' method is called,when u click the button to add a new tab.
Here the FXML file:
<TabPane fx:id="tabPane">
<Tab text="Willkommen" closable="true" >
<VBox>
<TitledPane text="Allgemeines" expanded="true">
<GridPane>
<Label text="Benutzername:" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<Label fx:id="username" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<Label text="Termine gesamt:" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<Label fx:id="dates" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Aufgaben gesamt:" GridPane.columnIndex="0" GridPane.rowIndex="2" />
<Label fx:id="toDos" GridPane.columnIndex="1" GridPane.rowIndex="2" />
</GridPane>
</TitledPane>
<TitledPane text="Aktuell" expanded="true" >
<ScrollPane>
<GridPane>
<Label text="Aktuelle Termine:" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<Label fx:id="actualDates" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<Label text="Aktuelle Aufgaben:" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<Label fx:id="actualToDos" GridPane.columnIndex="1" GridPane.rowIndex="1" />
</GridPane>
</ScrollPane>
</TitledPane>
</VBox>
</Tab>
</TabPane>
And here the Layout for a new Tab, also coded in a FXML file
<ScrollPane fx:id="scrollPane" minHeight="350.0" xmlns:fx="http://javafx.com/fxml" fx:controller="homenizer.controller.HomenizerController">
<VBox>
<TitledPane text="Termin" expanded="true">
<GridPane fx:id="datePane" alignment="TOP_LEFT" hgap="10" vgap="10" prefWidth="900" >
<Label text="Termin Beschreibung" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<TextField fx:id="dateInformation" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Datum" GridPane.columnIndex="0" GridPane.rowIndex="2" />
<TextField fx:id="dateOfDate" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="Termin beginn" GridPane.columnIndex="0" GridPane.rowIndex="3" />
<TextField fx:id="dateTimeBegin" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Termin ende" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<TextField fx:id="dateTimeEnd" GridPane.columnIndex="3" GridPane.rowIndex="3" />
<Label text="Priorität" GridPane.columnIndex="0" GridPane.rowIndex="4" />
<fx:define>
<ToggleGroup fx:id="priorityGroup" />
</fx:define>
<RadioButton text="Hoch" GridPane.columnIndex="1" GridPane.rowIndex="4" toggleGroup="$priorityGroup" />
<RadioButton text="Normal" GridPane.columnIndex="1" GridPane.rowIndex="5" toggleGroup="$priorityGroup"/>
<RadioButton text="Niedrig" GridPane.columnIndex="1" GridPane.rowIndex="6" toggleGroup="$priorityGroup"/>
</GridPane>
</TitledPane>
<TitledPane text="Person/Unternehmen" ellipsisString="Persson / Unternehmen" expanded="false" >
<GridPane fx:id="personCompanyPane" hgap="10" vgap="10">
<Label text="Name" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<TextField fx:id="name" GridPane.columnIndex="1" GridPane.rowIndex="0" />
<Label text="Vorname" GridPane.columnIndex="0" GridPane.rowIndex="1" />
<TextField fx:id="firstname" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Ort" GridPane.columnIndex="0" GridPane.rowIndex="2" />
<TextField fx:id="city" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="PLZ" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<TextField fx:id="place" maxWidth="60" GridPane.columnIndex="3" GridPane.rowIndex="2" />
<Label text="Strasse" GridPane.columnIndex="0" GridPane.rowIndex="3" />
<TextField fx:id="street" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Hausnr." GridPane.columnIndex="2" GridPane.rowIndex="3" />
<TextField fx:id="houseNr" maxWidth="35" GridPane.columnIndex="3" GridPane.rowIndex="3" />
<Label text="Unternehmen" GridPane.columnIndex="0" GridPane.rowIndex="4" />
<TextField fx:id="company" GridPane.columnIndex="1" GridPane.rowIndex="4" />
</GridPane>
</TitledPane>
<TitledPane text="Notiz" expanded="false" >
<GridPane>
<Label text="Notiz" GridPane.columnIndex="0" GridPane.rowIndex="0" />
<TextArea GridPane.columnIndex="0" GridPane.rowIndex="1" prefWidth="900" />
</GridPane>
</TitledPane>
<HBox>
<Button fx:id="check" text="bestätigen"
onAction="#onCheckRequest"/>
<Button fx:id="cancel" text="abbrechen" />
</HBox>
</VBox>
I hope this is enough of the code for analyse the problem :)
This is my Code, everytime I get a NullPointerException, but I don't know why. The TabPane is not empty, so I don't know why I get this Exception. This is my error code:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1456)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Node.fireEvent(Node.java:6867)
at javafx.scene.control.Button.fire(Button.java:179)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3369)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3209)
at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3164)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1582)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2267)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)
at com.sun.glass.ui.View.handleMouseEvent(View.java:530)
at com.sun.glass.ui.View.notifyMouse(View.java:924)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1453)
... 64 more
Caused by: java.lang.NullPointerException
at homenizer.controller.HomenizerController.onCheckRequest(HomenizerController.java:105)
... 74 more
Thanks for every help, I don't know if you need more of my code, but I'm sure that their is no error inj the rest of my code.
So I found my error :) I set the controller for my FXML in my controllercode and not in the FXML file itself and now it works
Related
Trying to load an FXML file in Eclipse and continue to get exceptions. Here is my main:
package application;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
static Tracker money = new Tracker(0,0,0);
static Tracker steel = new Tracker(0,0,0);
static Tracker titanium = new Tracker(0,0,0);
static Tracker plant = new Tracker(0,0,0);
static Tracker power = new Tracker(0,0,0);
static Tracker heat = new Tracker(0,0,0);
public static void main(String[] args) {
Application.launch(args);
}
#Override
public void start(Stage primaryStage){
try {
FXMLLoader loader = new FXMLLoader(Main.class.getResource("board.fxml"));
Parent root = (Parent) loader.load();
primaryStage.setScene(new Scene(root));
primaryStage.show();
} catch(NullPointerException e)
{
System.out.print("NullPointerException Caught");
e.printStackTrace();
}catch(IOException e) {
System.out.print("IOException Caught");
e.printStackTrace();
}
}
public static void nextGen() {
money.produce();
steel.produce();
titanium.produce();
plant.produce();
power.produce();
heat.produce();
}
public static void change() {
money.change();
steel.change();
titanium.change();
plant.change();
power.change();
heat.change();
}
}
I did the separate catches to see what is actually happening for Exceptions as I thought it was NullPointer at first (may still be that if a null val into the loader would give that) but the catch is happening with the IOException. I don't really know where to go from here, just would like some guidance.
EDIT
Added e.printStackTrace() per suggestion:
IOException Caughtjavafx.fxml.LoadException:
/C:/Users/pcher/eclipse-workspace/board/bin/application/board.fxml:8
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:933)
at javafx.fxml/javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:981)
at javafx.fxml/javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:230)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:755)
at javafx.fxml/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2808)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2634)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
at board/application.Main.start(Main.java:27)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: application.BoardCo
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:931)
... 17 more
Here is the FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<TitledPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" text="Terraforming Mars Tracker" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.BoardCo">
<content>
<GridPane prefHeight="388.0" prefWidth="598.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="154.0" minHeight="154.0" prefHeight="154.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="154.0" minHeight="154.0" prefHeight="154.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="113.0" minHeight="0.0" prefHeight="41.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TitledPane animated="false" text="Money">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<GridPane layoutX="-1.0" layoutY="-2.0" prefHeight="130.0" prefWidth="194.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField editable="false" text="Production:" GridPane.rowIndex="1" />
<TextField editable="false" text="Change:" GridPane.rowIndex="2" />
<TextField editable="false" text="Total:" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField editable="false" GridPane.columnIndex="1" />
</children>
</GridPane>
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="Steel" GridPane.columnIndex="1">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<GridPane layoutY="-1.0" prefHeight="130.0" prefWidth="194.0">
<children>
<TextField editable="false" text="Production:" GridPane.rowIndex="1" />
<TextField editable="false" text="Change:" GridPane.rowIndex="2" />
<TextField editable="false" text="Total:" />
<TextField editable="false" GridPane.columnIndex="1" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="Titanium" GridPane.columnIndex="2">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<GridPane layoutY="-1.0" prefHeight="130.0" prefWidth="194.0">
<children>
<TextField editable="false" text="Production:" GridPane.rowIndex="1" />
<TextField editable="false" text="Change:" GridPane.rowIndex="2" />
<TextField editable="false" text="Total:" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField editable="false" GridPane.columnIndex="1" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="Plant" GridPane.rowIndex="1">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<GridPane layoutY="-1.0" prefHeight="130.0" prefWidth="194.0">
<children>
<TextField editable="false" text="Production:" GridPane.rowIndex="1" />
<TextField editable="false" text="Change:" GridPane.rowIndex="2" />
<TextField editable="false" text="Total:" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField editable="false" GridPane.columnIndex="1" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="Power" GridPane.columnIndex="1" GridPane.rowIndex="1">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<GridPane layoutY="-1.0" prefHeight="130.0" prefWidth="194.0">
<children>
<TextField editable="false" text="Production:" GridPane.rowIndex="1" />
<TextField editable="false" text="Change:" GridPane.rowIndex="2" />
<TextField editable="false" text="Total:" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField editable="false" GridPane.columnIndex="1" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="Heat" GridPane.columnIndex="2" GridPane.rowIndex="1">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<GridPane layoutY="-1.0" prefHeight="130.0" prefWidth="194.0">
<children>
<TextField editable="false" text="Production:" GridPane.rowIndex="1" />
<TextField editable="false" text="Change:" GridPane.rowIndex="2" />
<TextField editable="false" text="Total:" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField editable="false" GridPane.columnIndex="1" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</AnchorPane>
</content>
</TitledPane>
<Button mnemonicParsing="false" onAction="#btnNextGenClicked" text="Next Generation" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<Button mnemonicParsing="false" onAction="#btnChangeClicked" text="Change" GridPane.columnIndex="1" GridPane.rowIndex="2" />
</children>
</GridPane>
</content>
</TitledPane>
And here is my controller (bare bones at the moment):
package application;
import javafx.fxml.FXML;
import javafx.event.ActionEvent;
public class BoardController {
// Event Listener on Button.onAction
#FXML
public void btnNextGenClicked(ActionEvent event) {
Main.nextGen();
}
// Event Listener on Button.onAction
#FXML
public void btnChangeClicked(ActionEvent event) {
Main.change();
}
}
I am trying to run the code of that is taken directly from primefaces website, but i am getting an error of UIInstructions cannot be cast to org.primefaces.model.menu.MenuElement
/This is my AddUser.xhtml code/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
>
<h:head>
<title>Getting User Information</title>
</h:head>
<h:body>
<h:form>
<p:menubar>
<p:submenu label="File" icon="ui-icon-document">
<p:submenu label="New" icon="ui-icon-contact">
<p:menuitem value="Project" url="#" />
<p:menuitem value="Other" url="#" />
</p:submenu>
<p:menuitem value="Open" url="#" />
<p:separator />
<p:menuitem value="Quit" url="#" />
</p:submenu>
<p:submenu label="Edit" icon="ui-icon-pencil">
<p:menuitem value="Undo" url="#" icon="ui-icon-arrowreturnthick-1-w" />
<p:menuitem value="Redo" url="#" icon="ui-icon-arrowreturnthick-1-e" />
</p:submenu>
<p:submenu label="Help" icon="ui-icon-help">
<p:menuitem value="Contents" url="#" />
<p:submenu label="Search" icon="ui-icon-search">
<p:submenu label="Text">
<p:menuitem value="Workspace" url="#" />
</p:submenu>
<p:menuitem value="File" url="#" />
</p:submenu>
</p:submenu>
<p:submenu label="Actions" icon="ui-icon-gear">
<p:submenu label="Ajax" icon="ui-icon-refresh">
<p:menuitem value="Save" actionListener="#{menuView.save}" icon="ui-icon-disk" update="messages"/>
<p:menuitem value="Update" actionListener="#{menuView.update}" icon="ui-icon-arrowrefresh-1-w" update="messages"/>
</p:submenu>
<p:submenu label="Non-Ajax" icon="ui-icon-newwin">
<p:menuitem value="Delete" actionListener="#{menuView.delete}" icon="ui-icon-close" update="messages" ajax="false"/>
</p:submenu>
</p:submenu>
<p:menuitem value="Quit" url="http://www.primefaces.org" icon="ui-icon-close" />
<f:facet name="options">
<p:inputText style="margin-right:10px" placeholder="Search"/>
<p:commandButton type="button" value="Logout" icon="ui-icon-extlink" />
</f:facet>
</p:menubar>
</h:form>
</h:body>
</html>
/This is my web.xml file/
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>UserWebApp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>afterdark</param-value>
</context-param>
<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/my.taglib.xml</param-value>
</context-param>
</web-app>
/And my jar file is also placed in webInf/lib/
I have tried everything available online but still unable o solve it
Thanks in advance
I figured out the problem. I was copying the MenuBar code directly from primefaces website (https://www.primefaces.org/showcase/ui/menu/menubar.xhtml)
And then i realized that there are invisible characters/stuff present between each line of code. (i figured this out when i copied/paste java class code),
once these invisible stuff id deleted and my code works perfectly.
/Following code is also the primefaces website code but free of invisible characters/
<h:form>
<p:growl id="messages"/>
<p:menubar>
<p:submenu label="File" icon="ui-icon-document">
<p:submenu label="New" icon="ui-icon-contact">
<p:menuitem value="Project" url="#" />
<p:menuitem value="Other" url="#" />
</p:submenu>
<p:menuitem value="Open" url="#" />
<p:separator />
<p:menuitem value="Quit" url="#" />
</p:submenu>
<p:submenu label="Edit" icon="ui-icon-pencil">
<p:menuitem value="Undo" url="#" icon="ui-icon-arrowreturnthick-1-w" />
<p:menuitem value="Redo" url="#" icon="ui-icon-arrowreturnthick-1-e" />
</p:submenu>
<p:submenu label="Help" icon="ui-icon-help">
<p:menuitem value="Contents" url="#" />
<p:submenu label="Search" icon="ui-icon-search">
<p:submenu label="Text">
<p:menuitem value="Workspace" url="#" />
</p:submenu>
<p:menuitem value="File" url="#" />
</p:submenu>
</p:submenu>
<p:submenu label="Actions" icon="ui-icon-gear">
<p:submenu label="Ajax" icon="ui-icon-refresh">
<p:menuitem value="Save" actionListener="#{menuView.save}" icon="ui-icon-disk" update="messages"/>
<p:menuitem value="Update" actionListener="#{menuView.update}" icon="ui-icon-arrowrefresh-1-w" update="messages"/>
</p:submenu>
<p:submenu label="Non-Ajax" icon="ui-icon-newwin">
<p:menuitem value="Delete" actionListener="#{menuView.delete}" icon="ui-icon-close" update="messages" ajax="false"/>
</p:submenu>
</p:submenu>
<p:menuitem value="Quit" url="http://www.primefaces.org" icon="ui-icon-close" />
<f:facet name="options">
<p:inputText style="margin-right:10px" placeholder="Search"/>
<p:commandButton type="button" value="Logout" icon="ui-icon-extlink" />
</f:facet>
</p:menubar>
</h:form>
This error can happen also for using HTML comments inside <p:contextmenu> between <p:menuitem>, which cause the error
UIInstructions cannot be cast to org.primefaces.model.menu.MenuElement
<p:contextmenu ...>
<!-- Menu Item XYZ -->
<p:menuitem ...>
I need to return all XML nodes whose ID attributes match between <Settings></Settings> and <Profile></Profile> and whose <Setting/> node has a Value attribute of true.
An example of my XML structure is found below:
<HBDI>
<Settings>
<Setting ID="PreferenceCode" Visible="true"/>
<Setting ID="SequenceCode" Visible="true"/>
<Setting ID="QuadrantScores" Visible="false"/>
<Setting ID="AdjectivePairs" Visible="false"/>
<Setting ID="ModeScores" Visible="true"/>
<Setting ID="Graph" Visible="true"/>
</Settings>
<Profile>
<PreferenceCode ID="PreferenceCode">3332</PreferenceCode>
<SequenceCode ID="SequenceCode">DCAB</SequenceCode>
<Graph ID="Graph">Graph.jpg</Graph>
<QuadrantScores ID="QuadrantScores">
<QuadrantScore Name="A" Value="3" />
<QuadrantScore Name="B" Value="3" />
<QuadrantScore Name="C" Value="23" />
<QuadrantScore Name="D" Value="46" />
</QuadrantScores>
<AdjectivePairs ID="AdjectivePairs">
<AdjectivePair Name="A" Value="4" />
<AdjectivePair Name="B" Value="7" />
<AdjectivePair Name="C" Value="9" />
<AdjectivePair Name="D" Value="10" />
</AdjectivePairs>
<ModeScores ID="ModeScores">
<ModeScore Name="Lt" Value="34" />
<ModeScore Name="Rt" Value="54" />
<ModeScore Name="Upr" Value="3" />
<ModeScore Name="Lwr" Value="24" />
</ModeScores>
</Profile>
</HBDI>
So what I want to achieve is to retrieve the following xml:
<HBDI>
<PreferenceCode ID="PreferenceCode">3332</PreferenceCode>
<SequenceCode ID="SequenceCode">DCAB</SequenceCode>
<Graph ID="Graph">Graph.jpg</Graph>
<ModeScores ID="ModeScores">
<ModeScore Name="Lt" Value="34" />
<ModeScore Name="Rt" Value="54" />
<ModeScore Name="Upr" Value="3" />
<ModeScore Name="Lwr" Value="24" />
</ModeScores>
</HBDI>
So, in the case of ID="PreferenceCode", it's corresponding Visible attribute in <Settings/> is true, thus it needs to be returned. I must admit that I have no idea on how to do the match-up between the IDs. Any help please?
When you are dealing with XML, use XQuery:
DECLARE #MyXML xml = '
<HBDI>
<Settings>
<Setting ID="PreferenceCode" Visible="true"/>
<Setting ID="SequenceCode" Visible="true"/>
<Setting ID="QuadrantScores" Visible="false"/>
<Setting ID="AdjectivePairs" Visible="false"/>
<Setting ID="ModeScores" Visible="true"/>
<Setting ID="Graph" Visible="true"/>
</Settings>
<Profile>
<PreferenceCode ID="PreferenceCode">3332</PreferenceCode>
<SequenceCode ID="SequenceCode">DCAB</SequenceCode>
<Graph ID="Graph">Graph.jpg</Graph>
<QuadrantScores ID="QuadrantScores">
<QuadrantScore Name="A" Value="3" />
<QuadrantScore Name="B" Value="3" />
<QuadrantScore Name="C" Value="23" />
<QuadrantScore Name="D" Value="46" />
</QuadrantScores>
<AdjectivePairs ID="AdjectivePairs">
<AdjectivePair Name="A" Value="4" />
<AdjectivePair Name="B" Value="7" />
<AdjectivePair Name="C" Value="9" />
<AdjectivePair Name="D" Value="10" />
</AdjectivePairs>
<ModeScores ID="ModeScores">
<ModeScore Name="Lt" Value="34" />
<ModeScore Name="Rt" Value="54" />
<ModeScore Name="Upr" Value="3" />
<ModeScore Name="Lwr" Value="24" />
</ModeScores>
</Profile>
</HBDI>'
SELECT #MyXML.query('
<HDBI> {
let $settings := /HBDI/Settings
for $element in /HBDI/Profile/*
where $settings/Setting[#ID = local-name($element) and #Visible = "true"]
return $element
} </HDBI>
')
The XQuery loops through each child node of the <Profile> tag and check if it's set to #Visible = "true" in the <Settings> node. local-name() gives the name of the current node.
Presently I am showing error messages at top location. But I want to show at place where i want i.e. near field. means error message for user name must be near to it.
When i am placing that tag there than it is showing null resource error.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Prime Faces Demo</title>
<link rel="stylesheet" href="second.css" type="text/css" />
</head>
<body>
<h:body>
<f:view>
<f:loadBundle var="mg" basename="messages1"></f:loadBundle>
<h:message for="firstname" style="color:red"></h:message>
<br></br>
<h:message for="lastname" style="color:red"></h:message>
<br></br>
<h:message for="pass" style="color:red"></h:message>
<br></br>
<h:message for="date" style="color:red"></h:message>
<br></br>
<h:message for="cpass" style="color:red"></h:message>
<br></br>
<h:message for="gender" style="color:red"></h:message>
<br></br>
<h:message for="nation" style="color:red"></h:message>
<br></br>
<h:message for="faci" style="color:red"></h:message>
<br></br>
<h:message for="padd" style="color:red"></h:message>
<br></br>
<h:message for="tadd" style="color:red"></h:message>
<br></br>
<h:message for="email" style="color:red"></h:message>
<br></br>
<h:message for="phone" style="color:red"></h:message>
<br></br>
<h:message for="quali" style="color:red"></h:message>
<br></br>
<h:message for="state" style="color:red"></h:message>
<br></br>
<h:message for="hobby" style="color:red"></h:message>
<br></br>
<h:message for="zone" style="color:red"></h:message>
<br></br>
<h:form>
<h:panelGrid columns="2" width="1000">
<h:panelGrid columns="2" width="600">
<p:outputLabel value="Enter first name" style="font-weight:bold"></p:outputLabel>
<h:inputText requiredMessage="#{mg.firstname}" value="#{Userdeatil.firstname}"
required="true" id="firstname">
</h:inputText>
<p:outputLabel value="Enter last name" style="font-weight:bold" ></p:outputLabel>
<h:inputText requiredMessage="#{mg.lastname}" value="#{Userdeatil.lastname}"
required="true" id="lastname">
</h:inputText>
<p:outputLabel value="Enter password" style="font-weight:bold"></p:outputLabel>
<p:password value="#{Userdeatil.password}" required="true" requiredMessage="#{mg.password}" id="pass"></p:password>
<p:outputLabel value="ReEnter password" style="font-weight:bold"></p:outputLabel>
<p:password value="#{Userdeatil.conpassword}" required="true" requiredMessage="#{mg.confrom}" id="cpass"></p:password>
<p:outputLabel value="Enter Date of Birth" style="font-weight:bold"></p:outputLabel>
<h:inputText requiredMessage="#{mg.birth}" value="#{Userdeatil.dob}"
required="true" id="date">
</h:inputText>
<p:outputLabel value="Select Gender" style="font-weight:bold" ></p:outputLabel>
<p:selectOneRadio value="#{Userdeatil.gender}" required="true" id="gender" requiredMessage="#{mg.gender}">
<f:selectItem itemValue="male" itemLabel="Male"></f:selectItem>
<f:selectItem itemValue="female" itemLabel="Female"></f:selectItem>
</p:selectOneRadio >
<p:outputLabel value="Select Nationality" style="font-weight:bold"></p:outputLabel>
<p:selectOneRadio value="#{Userdeatil.nation}" required="true" id="nation" requiredMessage="#{mg.nation}" >
<f:selectItem itemValue="indian" itemLabel="Indian"></f:selectItem>
<f:selectItem itemValue="nonindian" itemLabel="NonIndian"></f:selectItem>
<f:selectItem itemValue="nri" itemLabel="NRI"></f:selectItem>
</p:selectOneRadio >
<p:outputLabel value="Select Account Facilities" style="font-weight:bold" ></p:outputLabel>
<h:selectManyCheckbox required="true" id="faci" requiredMessage="#{mg.faci}">
<f:selectItem itemValue="1" itemLabel="Online banking"></f:selectItem>
<f:selectItem itemValue="2" itemLabel="Credit Card"></f:selectItem>
<f:selectItem itemValue="3" itemLabel="Debit Card"></f:selectItem>
<f:selectItem itemValue="4" itemLabel="All"></f:selectItem>
</h:selectManyCheckbox>
<p:outputLabel value="Permanent Address" style="font-weight:bold"></p:outputLabel>
<p:inputTextarea value="#{Userdeatil.tadd}" required="true" id="padd" requiredMessage="#{mg.padd}"></p:inputTextarea>
<p:outputLabel value="Temporary Address" style="font-weight:bold"></p:outputLabel>
<p:inputTextarea value="#{Userdeatil.padd}" required="true" id="tadd" requiredMessage="#{mg.tadd}"></p:inputTextarea>
<p:outputLabel value="Select if both are same" style="font-weight:bold"></p:outputLabel>
<p:selectBooleanCheckbox value="#{Userdeatil.same}"></p:selectBooleanCheckbox>
<p:outputLabel value="Select Zone" style="font-weight:bold"></p:outputLabel>
<h:selectOneMenu value="#{Userdeatil.zone}" id="zone" requiredMessage="#{mg.zone}">
<f:selectItem itemLabel="Northern" itemValue="" />
<f:selectItem itemLabel="Western"></f:selectItem>
<f:selectItem itemLabel="Eastern"></f:selectItem>
<f:selectItem itemLabel="Southern"></f:selectItem>
<f:selectItem itemLabel="Central"></f:selectItem>
</h:selectOneMenu>
<p:commandButton value="Submit" action="#{Userdeatil.check}"/>
</h:panelGrid>
<h:panelGrid columns="2" >
<p:outputLabel value="Enter email" style="font-weight:bold"></p:outputLabel>
<p:inputText value="#{Userdeatil.email}" required="true" id="email" requiredMessage="#{mg.email}">
</p:inputText>
<p:outputLabel value="Enter phone number" style="font-weight:bold" ></p:outputLabel>
<p:inputText value="#{Userdeatil.phone}" required="true" id="phone" requiredMessage="#{mg.phone}"></p:inputText>
<p:outputLabel value="Enter qualification" style="font-weight:bold"></p:outputLabel>
<p:inputText value="#{Userdeatil.quali}" required="true" id="quali" requiredMessage="#{mg.quali}"></p:inputText>
<p:outputLabel value="Enter State" style="font-weight:bold"></p:outputLabel>
<p:inputText value="#{Userdeatil.state}" required="true" id="state" requiredMessage="#{mg.state}"></p:inputText>
<p:outputLabel value="Enter Hobby" style="font-weight:bold"></p:outputLabel>
<p:inputMask value="#{Userdeatil.hobbey}" required="true" id="hobby" requiredMessage="#{mg.hobby}"/>
</h:panelGrid>
</h:panelGrid>
</h:form>
</f:view>
</h:body>
</body>
</html>
How to add AjaxBehavior to primefaces MenuItem.
I tried to add AjaxBehavior listenet for a menu item. But I get an exception that MenuItem does not support any Ajax Behavior.
How to add Ajax Behavior to menu item?
<h:form>
<p:growl id="messages" />
<h3>Default Menubar</h3>
<p:menubar>
<p:submenu label="File" icon="ui-icon-document">
<p:submenu label="New" icon="ui-icon-contact">
<p:menuitem value="Project" url="#" />
<p:menuitem value="Other" url="#" />
</p:submenu>
<p:menuitem value="Open" url="#" />
<p:separator />
<p:menuitem value="Quit" url="#" />
<p:ajax event="change" listener="#{workflowController.changeMenu}" execute="#this" ></p:ajax>
</p:submenu>
<p:submenu label="Edit" icon="ui-icon-pencil">
<p:menuitem value="Undo" url="#"
icon="ui-icon-arrowreturnthick-1-w" />
<p:menuitem value="Redo" url="#"
icon="ui-icon-arrowreturnthick-1-e" />
</p:submenu>
<p:submenu label="Help" icon="ui-icon-help">
<p:menuitem value="Contents" url="#" />
<p:submenu label="Search" icon="ui-icon-search">
<p:submenu label="Text">
<p:menuitem value="Workspace" url="#" />
</p:submenu>
<p:menuitem value="File" url="#" />
</p:submenu>
</p:submenu>
</p:menubar>
</h:form>
java code:
public void changeMenu(AjaxBehaviorEvent event) {
try {
Object selectOneMenuObject = (event.getSource());
MenuItem mi=(MenuItem) selectOneMenuObject;
String category = ((String) mi.getValue());
} catch (Exception e) {
log.info("class : EditPayeeProfileController,Method : changePayeeType "
+ e);
e.printStackTrace();
}
}
Error:
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/icareweb].[Faces Servlet]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception: javax.faces.view.facelets.TagException: /test1.xhtml at line 37 and column 51 Unable to attach to non-ClientBehaviorHolder parent
Use action
<p:menubar>
<p:menuitem label="Some action" action="#{bean.someAction}"/>
</p:menubar>
or actionListener attributes instead
<p:menubar>
<p:submenu label="My sub">
<p:menuitem value="Another action" actionListener="#{bean.otherActionListener}" />
</p:submenu>
</p:menubar>