You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Aanjaneya Shukla <aa...@vmware.com> on 2011/01/27 19:49:08 UTC

TextArea loading from a file

Hi,
I am trying to load a text file from json into the window as
JSON:
{
Text:"@sample.txt"
}
BXML:
<TextArea text="%Text"/>

So instead of loading the text into the TextArea from the file sample.txt, it only it shows '@sample.txt' as the text in the TextArea. 

Same logic works fine for images.

Thanks

Re: TextArea loading from a file

Posted by Greg Brown <gk...@verizon.net>.
> What I was trying to achieve was that my bxml pulls that text written in json and since it has '@' symbol so convert it to URL.

I understand. However, that syntax only works in BXML files. It does not work in resource (JSON) files.

> In this, only '@sample.txt' is displayed. But the aim was to display the text in sample.txt file. 
> So can the latter case be modified in such a way that I have the contents in the file as the text in my textarea. I don't want to declare the file location in my bxml as the file name to be loaded may change during runtime.

If the file name can change at runtime, you probably wouldn't want to put it in a resource file anyways, since resources are static and generally read only once at application startup. You could do this:

<TextArea text="$textLocation"/>

Then, before you read the BXML file, you can call:

bxmlSerializer.getNamespace().put("textLocation", new URL(...));

Then the text will be set to the contents of the file specified by the given URL.

G



RE: TextArea loading from a file

Posted by Aanjaneya Shukla <aa...@vmware.com>.
What I was trying to achieve was that my bxml pulls that text written in json and since it has '@' symbol so convert it to URL.
For example,
JSON:
{
Image:"@image.bmp"
}
BXML:
<ImageView image="%Image"/>

So in the above case the image is displayed. But when I try this,
JSON:
{
Text:"@sample.txt"
}
BXML:
<TextArea text="%Text"/>
In this, only '@sample.txt' is displayed. But the aim was to display the text in sample.txt file. 
So can the latter case be modified in such a way that I have the contents in the file as the text in my textarea. I don't want to declare the file location in my bxml as the file name to be loaded may change during runtime.

-----Original Message-----
From: Greg Brown [mailto:gk_brown@verizon.net] 
Sent: Friday, January 28, 2011 12:49 AM
To: user@pivot.apache.org
Subject: Re: TextArea loading from a file

The @ symbol is only converted to a URL when reading a BXML file. It doesn't work in a JSON file. You'll need to put your localized text in the JSON file itself.
G

On Jan 27, 2011, at 1:49 PM, Aanjaneya Shukla wrote:

> Hi,
> I am trying to load a text file from json into the window as
> JSON:
> {
> Text:"@sample.txt"
> }
> BXML:
> <TextArea text="%Text"/>
> 
> So instead of loading the text into the TextArea from the file sample.txt, it only it shows '@sample.txt' as the text in the TextArea. 
> 
> Same logic works fine for images.
> 
> Thanks


Re: TextArea loading from a file

Posted by Greg Brown <gk...@verizon.net>.
The @ symbol is only converted to a URL when reading a BXML file. It doesn't work in a JSON file. You'll need to put your localized text in the JSON file itself.
G

On Jan 27, 2011, at 1:49 PM, Aanjaneya Shukla wrote:

> Hi,
> I am trying to load a text file from json into the window as
> JSON:
> {
> Text:"@sample.txt"
> }
> BXML:
> <TextArea text="%Text"/>
> 
> So instead of loading the text into the TextArea from the file sample.txt, it only it shows '@sample.txt' as the text in the TextArea. 
> 
> Same logic works fine for images.
> 
> Thanks