You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Luiz Gustavo <lu...@gmail.com> on 2011/09/28 01:31:09 UTC

Unexpected character in input stream

Hi!

I'm having some troubles setting options up in a Prompt programmatically.
I'm attaching an image that shows the code with problems, part of the .json
file referenced and the error message I'm seeing when I open the
application.

Any ideas?

Thanksin advance!

Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com

Re: Unexpected character in input stream

Posted by Greg Brown <gk...@verizon.net>.
Looks like there were a couple of issues. You were missing a comma from Main.json after the "lblNoYesChoices" property on line 14. That was causing the parse error. 

You were also trying to pass a string value in your call to confirmCloseTabPrompt.setOptions() in Main.java (line 61). The resource value for "lblNo" was set to 'N\u00E3o', but setOptions() expects a list. You also called setOptions() twice in a row, once for "lblNo" and again for "lblYes". This would result in a prompt with only a single "Yes" option, which is probably not what you want. I think you either want to call:

confirmCloseTabPrompt.getOptions().add(resources.get("lblNo").toString());
confirmCloseTabPrompt.getOptions().add(resources.get("lblYes").toString());

or:

confirmCloseTabPrompt.setOptions(resources.get("lblNoYesChoices").toString());

G

On Sep 27, 2011, at 8:26 PM, Luiz Gustavo wrote:

> Sorry! I sent the e-mail accidentally, before finish writing it.
> 
> As I said, even loading resources like this:
> 
>         ...
>         
>         Charset charset = Charset.forName("UTF-8");
>         
>         Resources resources = new Resources(getClass().getName(), charset);
>                 
> I had the same error. I'm sending the files I'm working on (there are just 6 files and some images).
> 
> 
> Cheers,
> Luiz Gustavo
> 
> 2011/9/27 Luiz Gustavo <lu...@gmail.com>
> Greg,
> 
> 
> even trying to load resources like this:
> 
> 
>         
>         Charset charset = Charset.forName("UTF-8");
>         
>         Resources resources = new Resources(getClass().getName(), charset);
> 
>                 
> 
> 
> 
> 2011/9/27 Greg Brown <gk...@verizon.net>
> Maybe you are not saving the file as UTF-8? Or maybe you are saving it correctly, but reading it in with a different encoding?
> 
> On Sep 27, 2011, at 8:03 PM, Luiz Gustavo wrote:
> 
>> Hi Greg,
>> 
>> no, I didn't, but even typing the text directly I got the error. For example:
>> 
>> confirmCloseTabPrompt.setOptions("Sim"); /* It gives me the same error as if I had used resources */
>> 
>> Cheers,
>> Luiz Gustavo
>> 
>> 
>> 
>> 2011/9/27 Greg Brown <gk...@verizon.net>
>> Unicode escapes should work, but have you tried simply entering the character as Unicode (i.e. save the file in UTF-8)?
>> 
>> On Sep 27, 2011, at 7:53 PM, Luiz_Gustavo wrote:
>> 
>> > Well,
>> >
>> > I could solve my problem putting the options in the bxml, but still would
>> > like to know the reasons that lead to that problem.
>> > And another question: how could I input two localized options in a "options"
>> > property? I had to put both options in the .json entry because I didn't know
>> > how to do that on the bxml.
>> >
>> > http://apache-pivot-users.399431.n3.nabble.com/file/n3374425/encoding_solution.png
>> >
>> > --
>> > View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Unexpected-character-in-input-stream-tp3374340p3374425.html
>> > Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>> 
>> 
>> 
>> 
>> -- 
>> Luiz Gustavo S. de Souza
>> 
>> http://luizgustavoss.wordpress.com
>> 
>> 
> 
> 
> 
> 
> -- 
> Luiz Gustavo S. de Souza
> 
> http://luizgustavoss.wordpress.com
> 
> 
> 
> 
> 
> -- 
> Luiz Gustavo S. de Souza
> 
> http://luizgustavoss.wordpress.com
> 
> 
> <examples.zip>


Re: Unexpected character in input stream

Posted by Luiz Gustavo <lu...@gmail.com>.
Sorry! I sent the e-mail accidentally, before finish writing it.

As I said, even loading resources like this:

        ...

        Charset charset = Charset.forName("UTF-8");

        Resources resources = new Resources(getClass().getName(), charset);

I had the same error. I'm sending the files I'm working on (there are just 6
files and some images).


Cheers,
Luiz Gustavo

2011/9/27 Luiz Gustavo <lu...@gmail.com>

> Greg,
>
>
> even trying to load resources like this:
>
>
>
>         Charset charset = Charset.forName("UTF-8");
>
>         Resources resources = new Resources(getClass().getName(), charset);
>
>
>
>
>
> 2011/9/27 Greg Brown <gk...@verizon.net>
>
>> Maybe you are not saving the file as UTF-8? Or maybe you are saving it
>> correctly, but reading it in with a different encoding?
>>
>> On Sep 27, 2011, at 8:03 PM, Luiz Gustavo wrote:
>>
>> Hi Greg,
>>
>> no, I didn't, but even typing the text directly I got the error. For
>> example:
>>
>> confirmCloseTabPrompt.setOptions("Sim"); /* It gives me the same error as
>> if I had used resources */
>>
>> Cheers,
>> Luiz Gustavo
>>
>>
>>
>> 2011/9/27 Greg Brown <gk...@verizon.net>
>>
>>> Unicode escapes should work, but have you tried simply entering the
>>> character as Unicode (i.e. save the file in UTF-8)?
>>>
>>> On Sep 27, 2011, at 7:53 PM, Luiz_Gustavo wrote:
>>>
>>> > Well,
>>> >
>>> > I could solve my problem putting the options in the bxml, but still
>>> would
>>> > like to know the reasons that lead to that problem.
>>> > And another question: how could I input two localized options in a
>>> "options"
>>> > property? I had to put both options in the .json entry because I didn't
>>> know
>>> > how to do that on the bxml.
>>> >
>>> >
>>> http://apache-pivot-users.399431.n3.nabble.com/file/n3374425/encoding_solution.png
>>> >
>>> > --
>>> > View this message in context:
>>> http://apache-pivot-users.399431.n3.nabble.com/Unexpected-character-in-input-stream-tp3374340p3374425.html
>>> > Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>> --
>> Luiz Gustavo S. de Souza
>>
>> http://luizgustavoss.wordpress.com
>>
>>
>>
>>
>
>
> --
> Luiz Gustavo S. de Souza
>
> http://luizgustavoss.wordpress.com
>
>
>


-- 
Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com

Re: Unexpected character in input stream

Posted by Luiz Gustavo <lu...@gmail.com>.
Greg,


even trying to load resources like this:



        Charset charset = Charset.forName("UTF-8");

        Resources resources = new Resources(getClass().getName(), charset);




2011/9/27 Greg Brown <gk...@verizon.net>

> Maybe you are not saving the file as UTF-8? Or maybe you are saving it
> correctly, but reading it in with a different encoding?
>
> On Sep 27, 2011, at 8:03 PM, Luiz Gustavo wrote:
>
> Hi Greg,
>
> no, I didn't, but even typing the text directly I got the error. For
> example:
>
> confirmCloseTabPrompt.setOptions("Sim"); /* It gives me the same error as
> if I had used resources */
>
> Cheers,
> Luiz Gustavo
>
>
>
> 2011/9/27 Greg Brown <gk...@verizon.net>
>
>> Unicode escapes should work, but have you tried simply entering the
>> character as Unicode (i.e. save the file in UTF-8)?
>>
>> On Sep 27, 2011, at 7:53 PM, Luiz_Gustavo wrote:
>>
>> > Well,
>> >
>> > I could solve my problem putting the options in the bxml, but still
>> would
>> > like to know the reasons that lead to that problem.
>> > And another question: how could I input two localized options in a
>> "options"
>> > property? I had to put both options in the .json entry because I didn't
>> know
>> > how to do that on the bxml.
>> >
>> >
>> http://apache-pivot-users.399431.n3.nabble.com/file/n3374425/encoding_solution.png
>> >
>> > --
>> > View this message in context:
>> http://apache-pivot-users.399431.n3.nabble.com/Unexpected-character-in-input-stream-tp3374340p3374425.html
>> > Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Luiz Gustavo S. de Souza
>
> http://luizgustavoss.wordpress.com
>
>
>
>


-- 
Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com

Re: Unexpected character in input stream

Posted by Greg Brown <gk...@verizon.net>.
Maybe you are not saving the file as UTF-8? Or maybe you are saving it correctly, but reading it in with a different encoding?

On Sep 27, 2011, at 8:03 PM, Luiz Gustavo wrote:

> Hi Greg,
> 
> no, I didn't, but even typing the text directly I got the error. For example:
> 
> confirmCloseTabPrompt.setOptions("Sim"); /* It gives me the same error as if I had used resources */
> 
> Cheers,
> Luiz Gustavo
> 
> 
> 
> 2011/9/27 Greg Brown <gk...@verizon.net>
> Unicode escapes should work, but have you tried simply entering the character as Unicode (i.e. save the file in UTF-8)?
> 
> On Sep 27, 2011, at 7:53 PM, Luiz_Gustavo wrote:
> 
> > Well,
> >
> > I could solve my problem putting the options in the bxml, but still would
> > like to know the reasons that lead to that problem.
> > And another question: how could I input two localized options in a "options"
> > property? I had to put both options in the .json entry because I didn't know
> > how to do that on the bxml.
> >
> > http://apache-pivot-users.399431.n3.nabble.com/file/n3374425/encoding_solution.png
> >
> > --
> > View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Unexpected-character-in-input-stream-tp3374340p3374425.html
> > Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
> 
> 
> 
> 
> -- 
> Luiz Gustavo S. de Souza
> 
> http://luizgustavoss.wordpress.com
> 
> 


Re: Unexpected character in input stream

Posted by Luiz Gustavo <lu...@gmail.com>.
Hi Greg,

no, I didn't, but even typing the text directly I got the error. For
example:

confirmCloseTabPrompt.setOptions("Sim"); /* It gives me the same error as if
I had used resources */

Cheers,
Luiz Gustavo



2011/9/27 Greg Brown <gk...@verizon.net>

> Unicode escapes should work, but have you tried simply entering the
> character as Unicode (i.e. save the file in UTF-8)?
>
> On Sep 27, 2011, at 7:53 PM, Luiz_Gustavo wrote:
>
> > Well,
> >
> > I could solve my problem putting the options in the bxml, but still would
> > like to know the reasons that lead to that problem.
> > And another question: how could I input two localized options in a
> "options"
> > property? I had to put both options in the .json entry because I didn't
> know
> > how to do that on the bxml.
> >
> >
> http://apache-pivot-users.399431.n3.nabble.com/file/n3374425/encoding_solution.png
> >
> > --
> > View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/Unexpected-character-in-input-stream-tp3374340p3374425.html
> > Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>
>


-- 
Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com

Re: Unexpected character in input stream

Posted by Greg Brown <gk...@verizon.net>.
Unicode escapes should work, but have you tried simply entering the character as Unicode (i.e. save the file in UTF-8)?

On Sep 27, 2011, at 7:53 PM, Luiz_Gustavo wrote:

> Well,
> 
> I could solve my problem putting the options in the bxml, but still would
> like to know the reasons that lead to that problem.
> And another question: how could I input two localized options in a "options"
> property? I had to put both options in the .json entry because I didn't know
> how to do that on the bxml.
> 
> http://apache-pivot-users.399431.n3.nabble.com/file/n3374425/encoding_solution.png 
> 
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Unexpected-character-in-input-stream-tp3374340p3374425.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Unexpected character in input stream

Posted by Luiz_Gustavo <lu...@gmail.com>.
Well,

I could solve my problem putting the options in the bxml, but still would
like to know the reasons that lead to that problem.
And another question: how could I input two localized options in a "options"
property? I had to put both options in the .json entry because I didn't know
how to do that on the bxml.

http://apache-pivot-users.399431.n3.nabble.com/file/n3374425/encoding_solution.png 

--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Unexpected-character-in-input-stream-tp3374340p3374425.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.