Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 155
Registered: ‎01-22-2010
My Device: PlayBook -> 9900, 9810, 9800, 9700,9000, 8800, 8700...
My Carrier: AT&T
Accepted Solution

Localization internals

I have been struggling through using Netbeans for my Blackberry platform project.  (I tried eclipse and JDE both -- eclipse is filled with too many little frustrations, and JDE just doens't have the features I'm used to.)

 

I have pieced together bits and pieces of how to make this work,a nd plan to post a "how to" blog to ease the pain of future Netbeans users.  However, one thing I have not been able to track down yet is how to handle localization/resource bundles.

 

The localization sample projects don't shed much light - they seem to assume that you will be developing in the JDE, which makes localization transparent behind the scenes.  From what I can gather, RAPC is generating an interface file that contains const definitions for all of the resources.  This is behind the scenes - I can't find this file as an output anywhere.

 

I am trying to find out specifically how to generate only this interface file for availability in Netbeans -- whether it be the appropriate rapc.exe command line options (which I could include the netbeans ant script) or some other method. 

 

Has anyone had experience with this?

 



Try out BBSSH, a free Blackberry SSH client.
  • If you like my post, please let me know by Liking it!
  • If my post solved your problem please click on the Accept as Solution button.

Developer
Posts: 16,842
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Localization internals

you can find the interface in your temp folder. i add an interface to my eclipse project, but don't add it to the jde (as it is auto-generated).

If your resourcefiles are named ABC.rrc/rrh your interface needs to be named ABCResResource.

It has to devince long BUNDLE_ID and String BUNDLE_NAME (values are not important). you can define all your resource keys as int with the value 0.

 

I usually add the values in my dummy interface first and to the jde resource editor second.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 155
Registered: ‎01-22-2010
My Device: PlayBook -> 9900, 9810, 9800, 9700,9000, 8800, 8700...
My Carrier: AT&T

Re: Localization internals

Ahh, that may work - so you manually create /maintain the interface file in your project, then just exclude it from build?

 

 



Try out BBSSH, a free Blackberry SSH client.
  • If you like my post, please let me know by Liking it!
  • If my post solved your problem please click on the Accept as Solution button.

Developer
Posts: 16,842
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Localization internals

yes. if you were to ignore the errors of your IDE you could also let the jde generate the file (you can find it in the temp folder) but i usually think it better to just maintain it manually.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Posts: 155
Registered: ‎01-22-2010
My Device: PlayBook -> 9900, 9810, 9800, 9700,9000, 8800, 8700...
My Carrier: AT&T

Re: Localization internals

 

Thanks for your continued help & suggestions.  I'm finding BB to be a great platform, but I do wish that RIM hadn't decided that the JDE  or eclipse plugin would be al that anyone wants/needs to develop for their platform.  Separating their toolchain into component parts would make this a ton easier - getting a working end-to-end environment under netbeans (and Ant) has been more painful that it needed to be by far.

 

Anyway -  I've been trying intermittently to work through this, and keep running into problems. 

 

When I exclude the manually created interface file (BBSSHResources.java)  from precompile and jar phases, the rapc process with verbose output does show that it's processing the RRC/RRH  file -- and I can find the temporary .java file in the temp folder -- but it does not add the  .class file to the final COD. This results in ClassdefNotFound and similar at run time.  Alternatively, if I do include my manual interface, it includes that version directly and does not overwrite it when creating the COD - resulting in invaldi resource ids/names at runtime.

 

No combination of tricks I've been able to come up with works around this. Frustratingly, I have found several web sites that link to an article at jonathanfisher.co.uk's site -- describing exactly how to do  this with Netbeans, but it seems that he has pulled all of his BB-related content.  (Alas, google cache and archive.org don't have it either.)

 

So as far as I can tell, these are my options - in order of ease:

 

  1. Try to find a copy  of JDE 4.0, as it seems that the resource generator in 4.0 and earlier would actually generate the java file and keep it around, instead of tucking it into a temp directory and deleting it after a second or two.      This would probably be easiest since it would just mean I had to tab over to another tool to build my resources; I can include that java file in my final project and not worry about conflicts with whatever RAPC is doing.
  2. Create a resource-only COD and deploy it with my application. Use current JDE to maintain that, and add the output jar as a library to my netbeans project. Adds some complexity in that I might have to find a way to manually tweak my JAD file to include this as well.
  3. Write a simple resource parser that converts RRC to Java interface the same as RAPC does internally. Assuming resource bundle name is easy to generate (SHA1 of fully qualified class?) this actually may not be too bad and would allow me to integrate it directly into the ant build scripts. .

 

Is there sometihng obvious I'm misisng (hopefully)?  It really seems like in a JDE project, the RAPC process parses the RRH/RRC, creates the interface, and includes the .class file in the COD alomst as one step.    Perhaps this is because no separate preverify phase is done? (Netbeans does run preverify separately.)

 

 



Try out BBSSH, a free Blackberry SSH client.
  • If you like my post, please let me know by Liking it!
  • If my post solved your problem please click on the Accept as Solution button.

Developer
Posts: 155
Registered: ‎01-22-2010
My Device: PlayBook -> 9900, 9810, 9800, 9700,9000, 8800, 8700...
My Carrier: AT&T

Re: Localization internals

Oops - meant to say "BBSSHResource.java" - it's using the correct name, so that's not a cause of any troubles Smiley Happy



Try out BBSSH, a free Blackberry SSH client.
  • If you like my post, please let me know by Liking it!
  • If my post solved your problem please click on the Accept as Solution button.

Developer
Posts: 155
Registered: ‎01-22-2010
My Device: PlayBook -> 9900, 9810, 9800, 9700,9000, 8800, 8700...
My Carrier: AT&T

Re: Localization internals

Looks like option 1 was a false trail - I had read that it will generate the java interface  file and add it to the project,. Upon running it, that does not seem to be the case - output still goes to the temporary folder only.



Try out BBSSH, a free Blackberry SSH client.
  • If you like my post, please let me know by Liking it!
  • If my post solved your problem please click on the Accept as Solution button.

Developer
Posts: 155
Registered: ‎01-22-2010
My Device: PlayBook -> 9900, 9810, 9800, 9700,9000, 8800, 8700...
My Carrier: AT&T

Re: Localization internals

I followed option 2, and wrote up a tutorial for how I manage it.  I suspect there are a couple of things I need to clean up (detailed at the end of the tutorial), but this does resolve the issue.

 

Tutorial here: http://marcparadise.com/articles/blackberry-and-netbeans-localization-tutorial.html

 



Try out BBSSH, a free Blackberry SSH client.
  • If you like my post, please let me know by Liking it!
  • If my post solved your problem please click on the Accept as Solution button.