Primefaces TabView does not maintain selectOneMenu Values - dynamic

Hi I have a primefaces tabView looks like this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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></h:head>
<h:body>
<p:messages />
<h:form id="form">
<p:tabView dynamic="true">
<p:tab title="Tab">
<p:inputText required="true" value="value"></p:inputText>
</p:tab>
<p:tab title="Select">
<p:selectOneMenu value="#{dummyController.selectedValue}" id="select" required="true" requiredMessage="Select is required">
<f:selectItem itemValue="1" itemLabel="asd"></f:selectItem>
<f:selectItem itemValue="2" itemLabel="qwe"></f:selectItem>
<f:selectItem itemValue="3" itemLabel="zc"></f:selectItem>
</p:selectOneMenu>
<p:message for="select" />
</p:tab>
<p:tab title="Tab">
<p:inputText required="true" value="value"></p:inputText>
</p:tab>
</p:tabView>
<h:commandButton action="#{dummyController.submit}" />
</h:form>
</h:body>
</ui:composition>
and it's controller
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
#ManagedBean
#ViewScoped
public class DummyController implements Serializable {
private static final long serialVersionUID = 1L;
private int selectedValue;
public void submit() {
}
public int getSelectedValue() {
return selectedValue;
}
public void setSelectedValue(int selectedValue) {
this.selectedValue = selectedValue;
}
}
it has a strange behaviour, follow the steps tp reproduce:
open the Select tab
open other tab
press Submit twice
the first press nothing happens as regular, the next press triggers required message for the select, though it always has a value
Please tell if something is missing or if there are any solutions

There's no direct solution to this, it's a bug in primefaces tabView, I came with this workaround and worked
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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></h:head>
<h:body>
<p:messages />
<h:form id="form">
<p:tabView dynamic="true" activeIndex="#{dummyController.activeindex}" >
<p:tab title="Tab" id="tab1">
<p:inputText required="true" value="value"></p:inputText>
</p:tab>
<p:tab title="Select" id="selectTab">
<p:selectOneMenu disabled="#{dummyController.activeindex != 1}" value="#{dummyController.selectedValue}" id="select" required="true" requiredMessage="Select is required">
<f:selectItem itemValue="" itemLabel=""></f:selectItem>
<f:selectItem itemValue="1" itemLabel="asd"></f:selectItem>
<f:selectItem itemValue="2" itemLabel="qwe"></f:selectItem>
<f:selectItem itemValue="3" itemLabel="zc"></f:selectItem>
</p:selectOneMenu>
<p:message for="select" />
</p:tab>
<p:tab title="Tab" id="tab3">
<p:inputText required="true" value="value"></p:inputText>
</p:tab>
</p:tabView>
<h:commandButton action="#{dummyController.submit}" />
</h:form>
</h:body>
</ui:composition>
and the controller :
package com.ibm.sa.kap.ui.controller;
import java.io.Serializable;
#ManagedBean
#ViewScoped
public class DummyController implements Serializable {
private static final long serialVersionUID = 1L;
private int selectedValue;
private int activeindex;
public void submit() {
}
public int getSelectedValue() {
return selectedValue;
}
public void setSelectedValue(int selectedValue) {
this.selectedValue = selectedValue;
}
public int getActiveindex() {
return activeindex;
}
public void setActiveindex(int activeindex) {
this.activeindex = activeindex;
}
}
it's a conditional disabled according to the tab index, so that to prevent the tabview from resetting the value, how dirty !!

Unfortunatelly, the implementation of p:tabView with dynamic="true" is buggy. There are various issues: http://code.google.com/p/primefaces/issues/list?can=2&q=tabView+dynamic&colspec=ID+Type+Status+Priority+TargetVersion+Reporter+Owner+Summary&y=5000&cells=tiles but the most affected are the components such as p:selectOneMenu.
I've had this issue in my own project - the values from select lists were not submitted, if they were on the other tab as active. The solution is - don't use dynamic tabs, as long as they won't be fixed. There are too many bugs within.
Another thing that doesn't work, is to update the tab view from the ajax event onTabChange.

Because <p:selectOneMenu needs value to save element choosen.

Related

LoadException when trying to load new window fxml

I have javafx menu, I want to switch to another window. When I was using Java-8 everything worked, but now I switched to javafx-11 and java-11 and I cannot switch.
Switching code
AnchorPane pane = FXMLLoader.load(getClass().getResource("/main/main.fxml"), resources);
I was searching internet and stackoverflow and I tried following
1. In Inteliij idea I added all modules and libraries and applied the changes in Project Structure.
2. I added to src package module-info.java
3. I checked if fxml I am trying to load doesn´t contain any errors or unsed ids.
4. I checked names of controllers and fxmls I am trying to load
Code of the module-info.java
module duno {
requires javafx.fxml;
requires javafx.controls;
requires java.logging;
requires javafx.web;
opens main;
}
Code of the method from Controller which I am calling to get the Settings window
#FXML
void goto_settings(ActionEvent event) {
try {
ResourceBundle resources;
switch(settings.getLanguage().get(settings.getSelectedLanguage())) {
case "Czech":
resources = ResourceBundle.getBundle("/bundles/LangBundle_cz");
break;
default:
resources = ResourceBundle.getBundle("/bundles/LangBundle_en");
}
AnchorPane pane = load(getClass().getResource("/settings/settings.fxml"), resources);
rootpane.getChildren().setAll(pane);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
Settings Controller
package settings;
import duno.Serialization;
import duno.Settings;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.AnchorPane;
import javafx.stage.DirectoryChooser;
import main.Main;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* FXML Controller class
*
* #author Filip
*/
public class SettingsController implements Initializable {
#FXML
private AnchorPane rootpane;
#FXML
private ComboBox<String> adf_combobox;
#FXML
private ComboBox<String> pf_combobox;
#FXML
private CheckBox del_checkbox;
#FXML
private ComboBox<String> language_combobox;
private Settings settings;
/**
* Initializes the controller class.
*/
#Override
public void initialize(URL url, ResourceBundle rb) {
/*
Load old settings or create new if settings file doesnt exist
*/
Serialization ser = new Serialization();
String fileName = ser.getFolder() + "settings" + ser.getExt();
File f = new File(fileName);
if(f.exists() && !f.isDirectory()) {
try {
Settings oldSettings = (Settings) ser.deserialize("settings");
settings = oldSettings;
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
} else {
settings = new Settings();
}
/*
Setup the GUI
*/
adf_combobox.getItems().addAll(settings.getActiveDownloadFolder());
adf_combobox.getSelectionModel().select(settings.getSelectedActiveDownloadFolder());
pf_combobox.getItems().addAll(settings.getPreferredFormat());
pf_combobox.getSelectionModel().select(settings.getSelectedPreferredFormat());
del_checkbox.setSelected(settings.isDownloadEntireList());
language_combobox.getItems().addAll(settings.getLanguage());
language_combobox.getSelectionModel().select(settings.getSelectedLanguage());
}
#FXML
void addNewDownloadFolder(ActionEvent event) {
DirectoryChooser directoryChooser = new DirectoryChooser();
File selectedDirectory = directoryChooser.showDialog(rootpane.getScene().getWindow());
if(selectedDirectory == null){
// Nothing was selected
} else{
settings.addActiveDownloadFolder(selectedDirectory.getAbsolutePath());
System.out.println(settings.getActiveDownloadFolder().toString());
adf_combobox.getItems().setAll(settings.getActiveDownloadFolder());
}
}
#FXML
void removeSelectedDownloadFolder(ActionEvent event) {
if(adf_combobox.getItems().size() <= 1) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Warning Dialog");
alert.setHeaderText("You can´t remove this download folder");
alert.setContentText("You can´t remove all download folders");
alert.showAndWait();
} else {
int item = adf_combobox.getSelectionModel().getSelectedIndex();
settings.removeActiveDownloadFolder(item);
adf_combobox.getItems().setAll(settings.getActiveDownloadFolder());
adf_combobox.getSelectionModel().selectFirst();
}
}
#FXML
void saveSettings(ActionEvent event) {
settings.setSelectedActiveDownloadFolder(adf_combobox.getSelectionModel().getSelectedIndex());
settings.setSelectedPreferredFormat(pf_combobox.getSelectionModel().getSelectedIndex());
settings.setDownloadEntireList(del_checkbox.isSelected());
settings.setSelectedLanguage(language_combobox.getSelectionModel().getSelectedIndex());
System.out.println(settings.getLanguage().get(settings.getSelectedLanguage()));
Serialization ser = new Serialization();
String fileName = ser.getFolder() + "settings" + ser.getExt();
File f = new File(fileName);
if(f.delete()) {
System.out.println("File deleted");
ser.serialize(settings, "settings");
} else {
System.out.println("Settings file not deleted");
}
}
#FXML
void gotoDownloads(ActionEvent event) {
try {
ResourceBundle resources;
switch(settings.getLanguage().get(settings.getSelectedLanguage())) {
case "Czech":
resources = ResourceBundle.getBundle("bundles/LangBundle_cz");
break;
default:
resources = ResourceBundle.getBundle("bundles/LangBundle_en");
}
AnchorPane pane = FXMLLoader.load(getClass().getResource("/main/main.fxml"), resources);
rootpane.getChildren().setAll(pane);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Settings fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<AnchorPane id="AnchorPane" fx:id="rootpane" minHeight="800.0" minWidth="1000.0" prefHeight="800.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="settings.SettingsController">
<children>
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<MenuBar>
<menus>
<Menu mnemonicParsing="false" onAction="#gotoDownloads" text="Download">
<items>
<MenuItem mnemonicParsing="false" onAction="#gotoDownloads" text="Download" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Settings">
<items>
<MenuItem mnemonicParsing="false" text="Settings" />
</items>
</Menu>
</menus>
</MenuBar>
<GridPane GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="443.79998779296875" minWidth="10.0" prefWidth="272.8000244140625" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="561.4000396728516" minWidth="10.0" prefWidth="303.1999755859375" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="737.199951171875" minWidth="10.0" prefWidth="289.60002441406255" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="575.4000244140625" minWidth="10.0" prefWidth="121.20002441406245" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
</rowConstraints>
<children>
<Label text="%active_download_folder_text" />
<ComboBox fx:id="adf_combobox" prefHeight="26.0" prefWidth="294.0" GridPane.columnIndex="1" />
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="2">
<children>
<Button mnemonicParsing="false" onAction="#addNewDownloadFolder" text="%add_new_active_download_folder_button_text" />
<Button mnemonicParsing="false" onAction="#removeSelectedDownloadFolder" text="%remove_selected_active_download_folder_button_text" />
</children>
<padding>
<Insets top="5.0" />
</padding>
</HBox>
<Label text="%preferred_format_text" GridPane.rowIndex="1" />
<ComboBox fx:id="pf_combobox" prefHeight="26.0" prefWidth="114.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="1">
<opaqueInsets>
<Insets top="5.0" />
</opaqueInsets>
<padding>
<Insets top="5.0" />
</padding>
</HBox>
<Label text="%always_download_entire_list_text" GridPane.rowIndex="2" />
<CheckBox fx:id="del_checkbox" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="%language_text" GridPane.rowIndex="3" />
<ComboBox fx:id="language_combobox" prefHeight="26.0" prefWidth="162.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="3">
<padding>
<Insets top="5.0" />
</padding>
</HBox>
<Button mnemonicParsing="false" onAction="#saveSettings" text="%save_button_text" GridPane.columnIndex="3" GridPane.rowIndex="4" />
</children>
<padding>
<Insets left="20.0" top="10.0" />
</padding>
</GridPane>
</children>
</GridPane>
</children>
</AnchorPane>
It should load settings window as it did in java-8 but now I got and error
Run log
"C:\Program Files\Java\jdk-11.0.3\bin\java.exe" --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.1\lib\idea_rt.jar=50856:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.1\bin" -Dfile.encoding=UTF-8 -p C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.base.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.graphics.jar;E:\duno\out\production\duno;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx-swt.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.controls.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.fxml.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.media.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.swing.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.web.jar -m duno/main.Main
English
kvě 10, 2019 10:57:10 DOP. main.Controller goto_settings
SEVERE: null
javafx.fxml.LoadException:
/E:/duno/out/production/duno/settings/settings.fxml:17
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2625)
at javafx.fxml/javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:105)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:943)
at javafx.fxml/javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:980)
at javafx.fxml/javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:227)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:752)
at javafx.fxml/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2722)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2552)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3128)
at duno/main.Controller.goto_settings(Controller.java:184)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:76)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:273)
at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:83)
at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1782)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1670)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.controls/javafx.scene.control.MenuItem.fire(MenuItem.java:465)
at javafx.controls/com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1380)
at javafx.controls/com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.lambda$createChildren$12(ContextMenuContent.java:1333)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3851)
at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1200(Scene.java:3579)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1849)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2588)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
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:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalAccessException: class javafx.fxml.FXMLLoader$ValueElement (in module javafx.fxml) cannot access class settings.SettingsController (in module duno) because module duno does not export settings to module javafx.fxml
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
at java.base/jdk.internal.reflect.Reflection.ensureMemberAccess(Reflection.java:99)
at java.base/java.lang.Class.newInstance(Class.java:579)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:936)
... 66 more
Don´t mind the English in the output it´s just the language used in app
I figured it out on my own.
Here is how I proceeded.
I read the error several times, and then I though it need to export something. So I found that module info have exports something to something. So I added exports settings to javafx.fxml.
Another problem that I could not access settings because rootpane was private and settings were not opened. So I tried open settings; and it works :)
So here is final version
module duno {
requires javafx.fxml;
requires javafx.controls;
requires java.logging;
requires javafx.web;
exports settings to javafx.fxml;
opens main;
opens settings;
}
I hope it helps someone in future with same error

Primefaces upload file - image not refresh after upload

I have an issue after uploading an image. the image is not refreshed upon upload. The bean is session scoped, and after upload I need to refresh manually the page to see the new image. How can I refresh the graphical Image automatically after image/file upload? thank you
The following code could successfully upload the image but the previous image still visible and the new image could be visible only after refresh:
Platforms:
jsf 2.2
,tomcat 7.37
, primefaces 5.0
<h:form id="form" enctype="multipart/form-data">
<p:growl id="growl_1" showDetail="true"/>
<p:panelGrid id="pg_photo"
style="margin-bottom:10px;
width: 50em"
styleClass="panelGridCenter">
<f:facet name="header">
<p:row>
<p:column>
<p:graphicImage
id="gi_etud"
width="150"
height="120"
value="#{etudiantProfilView.imageEtudAsStream}"/>
</p:column>
<p:column>
<p:fileUpload id="fu_photo"
value="#{etudiantProfilView.imageEtudUF}"
mode="advanced"
dragDropSupport="true"
fileLimit="10"
sizeLimit="100000"
allowTypes="/(\.|\/)(gif|jpg|jpeg|gif|png|PNG|GIF|JPG|JPEG)$/"
auto="true"
update="growl_1 gi_etud"
fileUploadListener="#{etudiantProfilView.imageUploadListener}"
>
</p:fileUpload>
</p:column>
</p:row>
</f:facet>
</p:panelGrid>
</h:form>
The session bean:
#ManagedBean
#SessionScoped
public class EtudiantProfilView implements Serializable {
//some stuff
public void imageUploadListener(FileUploadEvent event) throws IOException {
//save the image to the hard disk
}
//some stuff
}
I have resolved the refresh issue by adding "reload" action to "oncomplete" attribute for uploadFile component:
<p:fileUpload id="fu_photo" value="#{etudiantProfilView.imageEtudUF}"
mode="advanced"
dragDropSupport="true"
fileLimit="10"
sizeLimit="200000"
allowTypes="/(\.|\/)(gif|jpg|jpeg|gif|png|PNG|GIF|JPG|JPEG)$/"
auto="true"
update="#form"
oncomplete="window.location.reload();"
fileUploadListener="#{etudiantProfilView.imageUploadListener}"
>
</p:fileUpload>

Struts 1.3 not able to validate using xml ValidatorForm

I am making simple login page and trying to validate it using struts ValidatorForm but its not working. But same code worked for DynaValidatorForm. Not able to understand what's problem.
It is not showing any error when I click login button.
Here is my code.
login.jsp
<body>
<div style="color:red">
<html:errors />
</div>
<html:form action="/Login" >
User Name : <html:text name="LoginForm" property="username" /> <br>
Password : <html:password name="LoginForm" property="password" /> <br>
<html:submit value="Login" />
</html:form>
</body>
LoginAction.java
public class LoginAction extends Action
{ public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
LoginForm loginForm=(LoginForm) form;
String userName = loginForm.getUsername();
String password = loginForm.getPassword();
if(userName.equals("sumeet") )
{
return mapping.findForward("success");
}
else
{
return mapping.findForward("failure");
}
struts.config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="LoginForm" type="com.ibm.Forms.LoginForm" >
</form-bean>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
</global-forwards>
<action-mappings>
<action name="LoginForm" path="/Login" scope="session" input="/login.jsp" type="com.ibm.Action.LoginAction" cancellable="true" validate="true">
<forward name="success" path="/success.jsp"/>
</action>
</action-mappings>
<message-resources parameter="test2.resources.ApplicationResources"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
valdiation.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN" "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd" >
<form-validation>
<formset>
<form name="LoginForm">
<field property="username" depends="required">
</field>
<field property="password" depends="required,minlength">
<arg1 key="${var:minlength}" name="minlength" resource="false"/>
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
Thank you.
You are missing the .do in the action attribute of the html form. You don't need the name attribute in both inputs.
<html:form action="/Login.do" >
User Name : <html:text property="username" /> <br>
Password : <html:password property="password" /> <br>
<html:submit value="Login" />
</html:form>

Can anyone please tell me what's wrong in this caml query code?

The Query:
<Where>
<Eq>
<FieldRef Name='Document Type' LookupId='True' />
<Value Type='Text'>Standards(STA)</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name='Number' Ascending='False'/>
</OrderBy>
<RowLimit>1</RowLimit>"
Code Context:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%# Import Namespace="System.IO" %>
<%# Import Namespace="Microsoft.SharePoint" %>
<%# Page Language="C#" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<html>
<head>
<meta name="WebPartPageExpansion" content="full" />
<meta name="ProgId" content="SharePoint.WebPartPage.Document" />
<h1>T-Site</h1>
<script runat="server" type="">
protected void sevak(object sender, EventArgs e)
string lastitem;
try
{
using (SPSite objsite = new SPSite("http://..."))
{
using (SPWeb objWeb = objSite.OpenWeb())
{
SPList objList = objWeb.Lists["...."];
SPQuery objQuery = new SPQuery();
objQuery.Query = "<Where><Eq><FieldRef Name='Document Type' LookupId='True' /> <Value Type='Text'>Standards(STA)</Value></Eq></Where><OrderBy><FieldRef Name='Number' Ascending='False'/></OrderBy><RowLimit>1</RowLimit>";
objQuery.Folder = objList.RootFolder;
SPListItemCollection colItems = objList.GetItems(objQuery);
if (colItems.Count>0)
{
lastitem=colItems(0);
}
else
{
Label1.Text="noItem";
}
}
}
}
catch (Exception ex)
{
return ex;
}
Label1.Text= "lastitem";
<SharePoint:CssLink runat="server"></SharePoint:CssLink>
<SharePoint:ScriptLink runat="server" language="javascript" name="core.js">
</SharePoint:ScriptLink>
<body>
<form id="form1" runat="server" action="Page-2.aspx">
<p>
<asp:Button runat="server" Text="Submit" id="Button1" OnClick="sevak" ></asp:Button>
</p>
<p><asp:Label runat="server" id="Label1"></asp:Label></p>
</form>
</body>
</html>
I think the problem is the field reference "Document Type":
The FieldRef elements expects an internal name of the referenced field. If the column "Document Type" was created via the UI the internal name of this column is "Document_x0020_Type".
You specifed LookupId="True" which causes a lookup against the id of a lookup field, but you provided a text value. Depending of your field type you should either provider the numeric ID of the document type or omit the LookupId="True" part to query against the text of the lookup field.

Edit Title in Silverlight 4

We are developing an out-of-browser Silverlight 4 application and want to change the title after the application loads.
Example:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
public string UserName { get; set; }
public string VersionNumber { get; set; }
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
string title = string.Format("MyApplication {0} {1} ", this.VersionNumber, this.UserName);
HtmlPage.Window.Eval(string.Format("document.title='{0}'", title));
}
}
Three things I have tried:
The above example does not work and throws an InvalidOperationException "The DOM/scripting bridge is disabled." All the references I found, example, said the HTML bridge is disabled in OOB mode.
Create a custom OOB Window, example, but I would prefer a more elegant solution.
Adjust the OutOfBrowserSettings.xml file, but it doesn't appear that I can get access to it after Load.
Any ideas on how to adjust the title after the application has loaded?
Unfortunately, the only way to do this is to create a custom OOB Window:
Look here and here for examples.
Try setting:
<param name="windowless" value="true"/>
<object id="SilverlightControlApp" data="data:application/x-silverlight-2," type="application/x-silverlight-2"
width="100%" height="100%">
<param name="source" value="ClientBin/MyTestApp.Client.xap" />
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50826.0" />
<param name="windowless" value="true"/>
<%-- <param name="minRuntimeVersion" value="3.0.40818.0" />--%>
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration: none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"
style="border-style: none" />
<%-- <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration: none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"
style="border-style: none" />--%>
</a>
</object>