Hi David,
Welcome to Pivot! Hopefully we can help you get some useful work done with it.... So, the BXMLSerializer class isn't doing anything particularly fancy to load a file. It will be calling (under the covers) the HelloBXML.class.getResource("xml/hello.bxml"...), which is just standard Java resource stuff. If you are running out of a .jar file, then the .bxml file would need to be in the .jar where the HelloBXML.class file is and accessible from the com/dwh/pivot/tutorial/xml path. The code in our application has lots of BXML resources located in various directories (within the .jar file), all underneath the main class location, so yes, it is definitely possible. You just need to follow the standard rules for locating Java resources. That first error you show ("could not find resources "/xml/hello.bxml") (if that is exactly the message) would have to have come from using a path of "/xml/hello.bxml", which is probably not what you want. The code you're showing (with the path of "xml/hello.bxml") should work if the file is placed (as I said) in the com/dwh/pivot/tutorials/xml directory. Bottom line, this isn't anything unique to Pivot -- we just use the class' package location as a starting point for locating the resource using the standard Java mechanisms.

HTH,
~Roger Whitcomb

On 9/27/13 6:57 PM, David Heard wrote:
Hello All,
I am new to apache-pivot although I do work with Spring MVC & Hibernate.
Before I pose this question I did go through the archive, from Jan. 2011 to current and I did not see an answer, and I did try Stackoverflow as well. What I would like to do is move the .bxml files to a separate directory - for example: /xml in the project.
eclipse is the IDE (Keppler) and the plugin is installed.
To make this shorter I'll use the excellent example of HelloBXML and just the relevant snippet of code;
@Overridepublicvoidstartup(Displaydisplay,Map<String,String>arg1)throwsException{
       BXMLSerializerbmxlSerializer =newBXMLSerializer();
window =(Window)bmxlSerializer.readObject(HelloBXML.class,"xml/hello.bxml");
       window.open(display);
}
I can get hello.bxml to load if I include it in the classpath as com.dwh.pivot.tutorial.xml or by itself as hello.bxml in com.dwh.pivot.tutorial where HelloBXML.java resides. When I tried creating the xml directory and calling hello.bxml from it I got the error: " I get an java.lang.IllegalArgumentException: could not find resource "/xml/hello.bxml". " I also tried using window =(Window)bmxlSerializer.readObject(getClass().getResource("xml/hello.bxml")); and I get a different error, "java.lang.IllegalArgumentException: location is null." After a little thought, I tried creating a separate package named xml and added hello.bxml to it. I received the same location is null error. What I would like to know is if it is possible to separate the files like that using pivot? My reasoning is I am trying to isolate the gui portions from the data or model. Maybe I am way out in left field and over thinking it. Thank you for taking time to look at this, if I am off base let me know :) I won't take offense. If I missed something somewhere point me at it and smack my hand.
Peace,
-Dave

Reply via email to