JavaFX Text and TextFlow Constructor Minutia - javafx

Why does adding to a TextFlow via a Text object constructed with method returning a plain String not work whereas adding to a Textflow via a Text object constructed with a reference to a String does work?

Related

Bind Custom Object Type in Xamarin Forms

I'm working with Xamarin Forms at the moment and I'm impressed by the MVVM concept and I try to use bindings as recommended. If I have a textfield that I want to display some text in I will bind that textfield to a string. The thing is though that I would like to bind this to a custom object-type instead. Let's say that it represents order id. The order id will be displayed as a string of a special format. Let's say it is always 10 characters, the 2 first are always country code, the rest are individual. This would be nice to have contained in an object that can validate it self. Is there any way that I can bind this custom object? How do I control how it is represented in the view? Should I use ToString()? This would be a bit unflexible since I would perhaps like to display this a bit differently in different context.
Any feedback would be helpful(except for the validation in itself for the order, I know how to do that).
Have you tried binding your text field to the custom object's property? Such as <Entry Text="{Binding CustomObject.Id}"/> or label.SetBinding(Label.TextProperty, "CustomObject.Id");
Label label = new Label();
// myObject is your custom object
label.BindingContext = myObject;
// MyPropertyName is some public property on your object you want to display
label.SetBinding(Label.TextProperty, "MyPropertyName");

Setting Extension Filter in FileChooser in javafx without description

I know a way of adding a file extension in FileChooser in javafx:
FileChooser chooser = new FileChooser();
chooser.getExtensionFilters().add("JPG Files(*.JPG)", "*.jpg");
But is there any way I can do this without any description argument and just care about the file extension?
Its not possible, as there is no such constructor for ExtensionFilter. There are two constructors and both need a description.
You need to pass a string in place of description, though you can pass an empty string "" ;)

Bind Flex component text to xml Node text for a desktop application

I have a tabNavigator with three tabs, on 2 tab pages I have a richtext control id = "characters" and id = "worlds", and on one a textarea control id = "objects".
How do I bind these to an xml file with nodes
(root>
(characters>* //text from richtext.text id = "characters" must go here on save*(characters>
(worlds> //text from richtext.text id = "worlds" must go here on save(/worlds>
(objects>* //text from textarea.text id = "objets" must go here on save*(/objects>
(/root>
(had to use brackets otherwise they dont show)
AND THEN
When I open the saved file the text in the xml nodes must write back into the three components in the tabnavigator.
Please help, I am doing a course and my assignment is to write a desktop software and save all user input in xml and I am just not getting it.
Thanks for any help and patience
I think you need to keep the XML/Actionscript Object Serialization seperate from anything to do with saving the state of your application/document.
To keep things simple you could create a presentation Model for your three views to bind all the data from your views like so:
PresentationModel.as
[Bindable]
public var characters:String;
[Bindable]
public var worlds:String;
[Bindable]
public var objects:String;
Once you have all your data collected from your users input you could then either use Flex based serialization libraries to change value/complex object to XML or simply use the objects inside of a method to manually construct your XML file.

whats the difference between an object and string object

I think i am lost with basics itself. What is the difference between these two. String object is an instance of String Class.
var guru:Object = new Object();
var guru:String = new String();
An object is a basic object. It has very few intrinsic properties and methods. More detail here
A string is an extended object that has the properties and methods relevant to strings. More detail here
If you're really not sure, I'd suggest looking up the answer here:
http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_11.html
Briefly, it states:
String data type
The String data type represents a
sequence of 16-bit characters. Strings
are stored internally as Unicode
characters, using the UTF-16 format.
Strings are immutable values, just as
they are in the Java programming
language. An operation on a String
value returns a new instance of the
string. The default value for a
variable declared with the String data
type is null. The value null is not
the same as the empty string (""),
even though they both represent the
absence of any characters.
Object data type
The Object data type is defined by the
Object class. The Object class serves
as the base class for all class
definitions in ActionScript. The
ActionScript 3.0 version of the Object
data type differs from that of
previous versions in three ways.
First, the Object data type is no
longer the default data type assigned
to variables with no type annotation.
Second, the Object data type no longer
includes the value undefined, which
used to be the default value of Object
instances. Third, in ActionScript 3.0,
the default value for instances of the
Object class is null.
If that doesn't satisfy your question, you're going to have to get more specific.
This guide can help you with basic Object Oriented questions regarding ActionScript 3.
The reference guide for String states that String inherits directly from Object.
The String class provides a bunch of useful methods that help with string manipulation on top of the few methods that Object provides (like toString()).

Flex HTTPService Resultformat

What is the real difference between these resultformats for HTTPService in Flex :
text
object
xml
e4x
Especially, the last three seem pretty close to each other by their description.
from the manual of HTTPService:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/http/HTTPService.html#resultFormat
object: The value returned is XML and is parsed as a tree of ActionScript objects. This is the default.
array: The value returned is XML and is parsed as a tree of ActionScript objects however if the top level object is not an Array, a new Array is created and the result set as the first item. If makeObjectsBindable is true then the Array will be wrapped in an ArrayCollection.
xml: The value returned is XML and is returned as literal XML in an ActionScript XMLnode object.
flashvars: The value returned is text containing name=value pairs separated by ampersands, which is parsed into an ActionScript object.
text: The value returned is text, and is left raw.
e4x: The value returned is XML and is returned as literal XML in an ActionScript XML object, which can be accessed using ECMAScript for XML (E4X) expressions.
The classtype of the returned object differs.
text => String
object => A generic object that you can use like a hash
e4x => an object of type XML
xml => I forget... a String?
I recently had some issues with the "object" and "e4x" resultFormat.
I have a base WebService Class that I use for sending requests and receiving results. By default, all results come back as "object". However, sometimes Flex looks at the data, and converts it to an appropriate type. For instance, if you have an XML result that looks like the following, it will convert it to an Array Object (not sure why...but...):
<root>
<child>text</child>
<child>text text</child>
</root>
Now, an Array Object like this can easily be cast as XML, since, as a string it is also XML.
However, some XML documents are returned as an ObjectProxy, which cannot be cast as XML, when the resultFormat is "object".
I tried using "e4x", as it was suggested here, but then I ran into problems with namespaces not being preserved correctly.
I finally tried "xml", and I am getting the expected results. It's interesting that when you inspect the event result property using the Flex Debugger, it is said to be an Array, even when you specify a resultFormat of "xml". I guess this allows for easily casting to ArrayCollection...not sure....

Resources