JavaFX Using alternative FXML structure for Title (Stage is root) - title

I read answer about putting Title in FXML (JavaFx : Set window title in fxml file), but I don't understand how to call this code.
I can't call it in the classic way:
FXMLLoader loader = new FXMLLoader(getClass().getResource("some.fxml"));
Scene scene = new Scene(loader.load());
Stage stage = new Stage();
stage.initOwner(root.getScene().getWindow());
stage.initModality(Modality.WINDOW_MODAL);
stage.setScene(scene);
stage.show();
some.fxml
<?xml version="1.0" encoding="utf-8"?>
<?import javafx.scene.layout.VBox?>
<?import javafx.stage.Stage?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Label?>
<Stage title="Some Stage">
<scene>
<Scene>
<VBox xmlns:fx="http://javafx.com/fxml">
<children>
<Label text="John Doe"/>
</children>
</VBox>
</Scene>
</scene>
</Stage>

Because the fxml is creating a stage, you don't need to create another stage in your Java code, just get a reference to the stage created by FXML and show it directly.
StageLoader.java
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.*;
import java.io.IOException;
public class StageLoader extends Application {
private void showDialog(Stage owner) {
try {
FXMLLoader loader = new FXMLLoader(
getClass().getResource("some.fxml")
);
Stage dialog = loader.load();
dialog.initOwner(owner);
dialog.initModality(Modality.WINDOW_MODAL);
dialog.initStyle(StageStyle.UTILITY);
dialog.show();
} catch (IOException e) {
System.out.println("Unable to load dialog FXML");
e.printStackTrace();
}
}
#Override
public void start(final Stage stage) throws IOException {
Button openDialog = new Button("Open Dialog");
openDialog.setOnAction(event -> showDialog(stage));
stage.setTitle("Main Window");
stage.setScene(
new Scene(
new StackPane(openDialog),
200, 200
)
);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
I made a couple of minor modifications to the fxml to ensure the resultant stage is large enough to actually see the dialog stage title.
some.fxml
<?xml version="1.0" encoding="utf-8"?>
<?import javafx.scene.layout.VBox?>
<?import javafx.stage.Stage?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Label?>
<Stage title="Some Stage" resizable="false" xmlns:fx="http://javafx.com/fxml" >
<scene>
<Scene>
<VBox >
<children>
<Label text="John Doe" prefWidth="150"/>
</children>
</VBox>
</Scene>
</scene>
</Stage>
SceneBuilder who can't open FXML after adding Stage and Scene tags.
You could write the FXML with the stage and scene definitions as an outer shell with an embedded <fx:include..> statement to include an inner FXML document which could be opened edited directly in SceneBuilder. Also, you could create a feature request against SceneBuilder (it is called the "design tool" in the issue tracker), to request direct support for FXML files with stage roots and scenes included in the FXML.

Related

Failed to instantiate file "app.module.ts" from module "RootModule"

I have sharepoint add-in project, I have inculuded necessary angular2 packages and ts files as you see ss of solution explorer in below:
and here is my ts file contents;
boot.ts
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app.component';
bootstrap(AppComponent)
app.component.ts
import {Welcome} from './app.module';
import {Component} from 'angular2/core';
#Component({
selector: 'app-main',
template:'<h1>${Welcome.getMessage()}</h1>'
})
export class AppComponent {}
app.module.ts
export class Welcome {
static getMessage() {
return "Hello World!";
}
}
when I run this application I always get this error message in output window:
> #"Error 1
> CorrelationId: ae2bcaba-cdac-4178-bd39-2aca278a2e31
> ErrorDetail: There was a problem with activating the app web definition.
> ErrorType: App
> ErrorTypeName: App Related
> ExceptionMessage: Failed to instantiate file "app.module.ts" from module "RootModule": Source path
> "Features\SharePointAddIn4_Feature1\app.module.ts" not found.
> Source: AppWeb
> SourceName: App Web Deployment
I have search but cant find any solution helped me.. any idea how to fix this?
To resolve this, I had to set the tsconfig.json file (and others) to not deploy, and remove it from Elements.xml in the root of the project.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="RootModule">
</Module>
</Elements>
Hey Buddy there are few points to be clear here before answer
you are using too old version of angular2 may be you are in angular2 beta
(as you are using 'angular2/core' now it is '#angular/*')
you are using wrong syntax according to me
{Welcome.getMessage()}
there are syntax like this
{{Welcome.getMessage()}}
also you are trying to access class Welcome without even initializing in the constructor of app.component.ts file, which is wrong .

Alfresco custom aikau footer

I want to customize Alfresco aikau footer. For the beginning I would like to inject custom html-template in AlfShareFooter. So far I created an extension:
<extension>
<modules>
<module>
<id>MyCmpny widgets</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<configurations>
<config evaluator="string-compare" condition="WebFramework" replace="false">
<web-framework>
<dojo-pages>
<packages>
<package name="mycmpny" location="js/mycmpny"/>
</packages>
</dojo-pages>
</web-framework>
</config>
</configurations>
</module>
</modules>
</extension>
Html template for the footer and now I'm trying to override templateString of the AlfShareFooter object:
define(["dojo/_base/declare",
"alfresco/footer/AlfShareFooter'",
"dojo/text!./templates/ep-footer.html"],
function (declare, AlfShareFooter, template) {
return declare([AlfShareFooter], {
templateString: template
})
});
But it doesn't work. I am not familiar with Dojo and I think the problem is in the syntax...
I've found out how to override template:
define(["dojo/_base/declare",
"dojo/text!./templates/my-footer.html",
"alfresco/footer/AlfShareFooter"],
function (declare, template, AlfShareFooter) {
return declare([AlfShareFooter],{
postMixInProperties: function my_footer_AlfShareFooter__postMixInProperties(){
this.inherited(arguments);
this.templateString = template;
}
});
});
But with g̶r̶e̶a̶t̶ custom footer template comes g̶r̶e̶a̶t̶ custom css and i18n... So I wrote a post about changing Aikau footer in Alfresco.

read and writing file using mozilla xul

I've got a problem with reading and writing files in mozilla xul.
At first I want simply to read path to file(to check whether I/O works)
So I wrote this code
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="window" title="title">
<script>
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var file = FileUtils.getFile("Desk", ["temp.xml"]);
alert(file.path);
</script>
</window>
It should show alert window with path to temp.xml(this file exists on desktop). But it shows nothing in mozilla firefox.
what's the problem?
My Firefox shows two problems:
it chokes on alert() with error:
Error: Cannot call openModalWindow on a hidden window =
NS_ERROR_NOT_AVAILABLE Source file:
resource://gre/components/nsPrompter.js Line: 382
Your window has no style, so it's "invisible"
Here is a work around with displaying the path in a textbox instead and in browser console
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="window" title="title">
<textbox id="text" value="N/A"/>
<script type="application/javascript">
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var file = FileUtils.getFile("Desk", ["temp.xml"]);
document.getElementById("text").value = file.path;
console.log(file.path);
//alert(file.path);
</script>
</window>

Flex mobile - tabbed application data http service

Flex Mobile Project
I have a tabbed application with a http service.
I would like to load the data, and once it is loaded pass it to the first tab, so the first tab can show a list with some data of the http service
I would like to use the firstViewData property of the tab (as probably on the future I will send different data to each tab)
I have tried the following but I get no data on the view :-(
On the main application
<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:wsdatos="services.wsdatos.*"
creationComplete="tabbedviewnavigatorapplication1_creationCompleteHandler(event)"
applicationDPI="160">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
public var WS:ArrayCollection;
protected function operation1():void
{
Operation1Result.token = wSDatos.Operation1();
}
protected function tabbedviewnavigatorapplication1_creationCompleteHandler(event:FlexEvent):void
{
operation1();
}
protected function wSDatos_resultHandler(event:ResultEvent):void
{
WS = event.result as ArrayCollection;
}
]]>
</fx:Script>
<s:ViewNavigator label="Home" width="100%" height="100%" firstView="views.HomeView" firstViewData="{WS}"/>
<s:ViewNavigator label="Publicidad" width="100%" height="100%" firstView="views.PublicidadView"/>
<s:ViewNavigator label="Eventos" width="100%" height="100%" firstView="views.EventosView"/>
<fx:Declarations>
<s:CallResponder id="Operation1Result"/>
<wsdatos:WSDatos id="wSDatos" result="wSDatos_resultHandler(event)"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:TabbedViewNavigatorApplication>
On the home view
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Home">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:List width="100%" height="100%" dataProvider="{data}" labelField="Nombre"/>
</s:View>
I am just new in Flex so I am probably missing basic concepts...
Any help on how to pass the data ?
The sample below works really fine on a not tabbed application, I just use navigator.pushView(views.HomeView event.result as ArrayCollection); on the function wSDatos_resultHandler (No need to use the var WS)
So I am trying to do somehting similiar on a tabbed application
Thanks!
One thing you'll need to do is mark your variable WS as [Bindable]. Without this, there is no notification sent when the data changes.
What's happening is that the view is created and the data from WS (initially unspecified) is used to display; then the HTTP request populates the WS return value, but since it's not marked Bindable the view isn't notified to update.

object object embedded in square bracket in combobox

Following is my code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.utils.ArrayUtil;
import mx.utils.ObjectUtil;
[Bindable]
private var zipdataProvdr:ArrayCollection = new ArrayCollection([{name: "test", file: "test"},{name: "elm34001", file: "elm34001"}, {name: "elm34003", file: "elm34003"}, {name: "elm34005", file: "elm34005"}, {name: "elm34009", file: "elm34009"},{name: "elm34011", file: "elm34011"}, {name: "elm34013", file: "elm34013"}]);
]]>
</mx:Script>
<mx:ComboBox
id="cbobxz"
dataProvider="{zipdataProvdr}"
x="10" y="49" width="189" height="23">
</mx:ComboBox>
<mx:Label x="247" y="48" text="ShapeFiles" width="78" height="24"/>
<mx:ComboBox x="350" y="50" id="cbobxs" dataProvider=""></mx:ComboBox>
</mx:Application>
On the browser I should see a dropdown box with all the files by their names, instead I can see a dropdown box with [object object].
You want to change your code to use label instead of name:
private var zipdataProvdr:ArrayCollection = new ArrayCollection([{label: "test", file: "test"},{label: "elm34001", etc.