Flex, States and inheritance - flex3

Is it possible to have a child class which adds states to the set of states which are defined in the base class? Currently it looks like my child class overrides all of the states in the base class.

In your child component, create a separate array of states declaratively and in the preinitialize event concatenate them. See this example.
<!-- MyParent -->
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
<mx:Script>
<![CDATA[
import mx.controls.Button;
private function onCreationComplete():void {
for each(var state:State in states) {
var button:Button = new Button();
button.label = state.name;
button.addEventListener(MouseEvent.CLICK, onClick);
addChild(button);
}
}
private function onClick(event:MouseEvent):void {
currentState = Button(event.target).label;
}
]]>
</mx:Script>
<mx:states>
<mx:State name="Red">
<mx:SetStyle name="backgroundColor" value="#FF0000" />
</mx:State>
<mx:State name="Green">
<mx:SetStyle name="backgroundColor" value="#00FF00" />
</mx:State>
<mx:State name="Blue">
<mx:SetStyle name="backgroundColor" value="#0000FF" />
</mx:State>
</mx:states>
</mx:VBox>
<!-- MyChild -->
<?xml version="1.0" encoding="utf-8"?>
<MyParent xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" preinitialize="onPreinitialize()">
<mx:Script>
<![CDATA[
private function onPreinitialize():void {
states = states.concat(newStates);
}
]]>
</mx:Script>
<mx:Array id="newStates">
<mx:State name="Cyan">
<mx:SetStyle name="backgroundColor" value="#00FFFF" />
</mx:State>
<mx:State name="Purple">
<mx:SetStyle name="backgroundColor" value="#FF00FF" />
</mx:State>
</mx:Array>
</MyParent>
<!-- MyApp -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
minWidth="955"
minHeight="600" xmlns="*">
<MyParent width="50%" height="100%" />
<MyChild width="50%" height="100%" right="0" />
</mx:Application>

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

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>

variable to custom component - flex

I'm trying to pass a variable from my main flex application to a custom component I've created, but haven't really figured anything out.
my variable is just a string - public var test:String = "a test";
my custom component is implement in my main application like this - <ns1:finaltest includeIn="FinalTest" x="26" y="19" />
In my custom component 'finaltest' I'd like just to display the variable 'test'. something like this - finalmessage.text = test;
MainApp.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" xmlns:local="*"
>
<fx:Script>
<![CDATA[
[Bindable]
public var test:String = "a test";
]]>
</fx:Script>
<local:FinalTest finalMessage="{test}" />
</s:Application>
FinalTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="400" height="300"
>
<fx:Script>
<![CDATA[
[Bindable]
public var finalMessage:String;
]]>
</fx:Script>
<s:Label text="{finalMessage}" />
</s:Group>

FlashBuilder 4/Flex, set transparent background for web app?

I'm embeding a flex application into a web page using the most recent version of swfobject.js. I've set wmode to transparent and all that but whatever I've enterd for the embeded objects default size, is then a white background within my application. I've set the application's backgroundAlpha to 0 and I know that part works because my aplication resizes after it has finished loading. The resized portion of the application is transparent but the rest still has the white background so it's obvious it has something to do with the application and not the html or javascript embedding it. How do i fix this?
Looking at the default application skin I noticed that it makes use of the backgroundColor style property to set the fill color for the backgroundRect of the applicaton. However, there's no mention of backgroundAlpha so I created a new application skin and added a single line of code which works!
Below this line:
bgRectFill.color = getStyle('backgroundColor');
Add the following:
bgRectFill.alpha = getStyle('backgroundAlpha');
In your application .mxml file set the skinClass property to:
skinClass="YourSkinsDirectory.YourApplicationSkin"
I have mine saved as ApplicationSkin.mxml in a folder called Skins
so mine looks like this: skinClass="Skins.ApplicationSkin"
Here's the full skin:
<?xml version="1.0" encoding="utf-8"?>
<!--
ADOBE SYSTEMS INCORPORATED
Copyright 2008 Adobe Systems Incorporated
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the license agreement accompanying it.
-->
<!--- The default skin class for the Spark Application component.
#see spark.components.Application
#langversion 3.0
#playerversion Flash 10
#playerversion AIR 1.5
#productversion Flex 4
-->
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:fb="http://ns.adobe.com/flashbuilder/2009" alpha.disabled="0.5" alpha.disabledWithControlBar="0.5">
<fx:Metadata>
<![CDATA[
/**
* A strongly typed property that references the component to which this skin is applied.
*/
[HostComponent("spark.components.Application")]
]]>
</fx:Metadata>
<fx:Script fb:purpose="styling">
<![CDATA[
/**
* #private
*/
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number) : void
{
bgRectFill.color = getStyle('backgroundColor');
bgRectFill.alpha = getStyle('backgroundAlpha');
super.updateDisplayList(unscaledWidth, unscaledHeight);
}
]]>
</fx:Script>
<s:states>
<s:State name="normal" />
<s:State name="disabled" />
<s:State name="normalWithControlBar" />
<s:State name="disabledWithControlBar" />
</s:states>
<!-- fill -->
<!---
A rectangle with a solid color fill that forms the background of the application.
The color of the fill is set to the Application's backgroundColor property.
-->
<s:Rect id="backgroundRect" left="0" right="0" top="0" bottom="0">
<s:fill>
<!--- #private -->
<s:SolidColor id="bgRectFill" color="#FFFFFF" alpha="1"/>
</s:fill>
</s:Rect>
<s:Group left="0" right="0" top="0" bottom="0">
<s:layout>
<s:VerticalLayout gap="0" horizontalAlign="justify" />
</s:layout>
<!---
#private
Application Control Bar
-->
<s:Group id="topGroup" minWidth="0" minHeight="0"
includeIn="normalWithControlBar, disabledWithControlBar" >
<!-- layer 0: control bar highlight -->
<s:Rect left="0" right="0" top="0" bottom="1" >
<s:stroke>
<s:LinearGradientStroke rotation="90" weight="1">
<s:GradientEntry color="0xFFFFFF" />
<s:GradientEntry color="0xD8D8D8" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect>
<!-- layer 1: control bar fill -->
<s:Rect left="1" right="1" top="1" bottom="2" >
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xEDEDED" />
<s:GradientEntry color="0xCDCDCD" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<!-- layer 2: control bar divider line -->
<s:Rect left="0" right="0" bottom="0" height="1" alpha="0.55">
<s:fill>
<s:SolidColor color="0x000000" />
</s:fill>
</s:Rect>
<!-- layer 3: control bar -->
<!--- #copy spark.components.Application#controlBarGroup -->
<s:Group id="controlBarGroup" left="0" right="0" top="1" bottom="1" minWidth="0" minHeight="0">
<s:layout>
<s:HorizontalLayout paddingLeft="10" paddingRight="10" paddingTop="7" paddingBottom="7" gap="10" />
</s:layout>
</s:Group>
</s:Group>
<!--- #copy spark.components.SkinnableContainer#contentGroup -->
<s:Group id="contentGroup" width="100%" height="100%" minWidth="0" minHeight="0" />
</s:Group>
</s:Skin>

How can I change (from JavaScript) the title of a XUL window?

In a xulrunner app, I seem to be unable to set the title from JavaScript. I have tried setting in these two ways:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="mywindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="go();">
<!-- your code here -->
<script type="application/x-javascript">
<![CDATA[
function go(){
document.getElementById("mywindow").title="blar";
document.getElementById("mywindow").setAttribute("title","blar");
}
]]>
</script>
</window>
DOM Inspector shows that the title attribute does get updated, but it does not show up on screen.
[CDATA[
function entry_onLoad()
{
document.title = "MyTitle"
}
addEventListener("load", entry_onLoad, false)
]]>
This works
It appears that after the page loads one cannot change the window. If there is a way, I'd be interested to know it.. but this does work:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="mywindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
<script type="application/x-javascript">
<![CDATA[
function go(){
document.getElementById("mywindow").title="blar";
}
go();
]]>
</script>
</window>