Hi Andrew,
wow, lots of questions :)

Andrew Madu wrote:
Hi Simone,
many thanks for your reply. Would you by any chance have an example of a very simple process done in a .js and .java version? 

I take it that I can still reference the java classes from my sitemap as I would do the flowscripts?:


 <map:flow language="java">
  <map:script src=""/>
 </map:flow>
Nearly. In the normal way, the class must be in classpath (so either a jar in WEB-INF/lib or in classes) and referenced with its fully qualified name, so for example <map:script src=""/> . This unfortunately means that you will have to recompile your flows and restart the server for each change you make.

Another approach is the compiling classloader, that compiles from source code, and thus avoids all the rebuild/restart problems. I haven't used this myself, and can't give you much help on this subject.

How would I reference method calls from the site map to java methods? In _javascript_ it would be:

<map:call function="terms">
<map:parameter name="page_Name" value="account"/>
</map:call>

Would I be correct in thinking that I would do:

<map:call login.user="terms">
<map:parameter name="page_Name" value="account"/>
</map:call>
Unfortunately no. Every method you wish to call from the sitemap must be public, void, with no parameters, and called doSomethingToDo. You will then call it from the sitemap with <map:call function="somethingToDo"/> . The "function name space" is flat, so if you have two methods with the same name in two different classes (or in two different _javascript_s) it will be a problem.

How would I read the parameter into the class/method from the sitemap? Like so?:

private String artistID = cocoon.parameters.artistID;
Nearly : String artistID = getParameters().get("artistID");

Would I pass it from the sitemap the same was as shown above?: <map:parameter name="page_Name" value="account"/>
Yes, the same.

What about persisting data? I have a variable which persists a user object after a user has logged in:

var userGlobal = cocoon.session.getAttribute("user");

Would the javaflow equiv be:

private Object userGlobal = cocoon.session.getAttribute("user"); ???
Hey, pay attention. In Javaflow AND in flowscript, global variabiles are quite dangerous : they are global in the real sense, can span different user sessions, you should not use them if not for singleton classes, or other really global data like configuration.

Also, they are not continuation-safe, so i always go for local variables :

// This is a singleton class, so no danger in using it as global.
private ShoppingCartManager cartManager = ShoppingCartManager.getInstance();

public void doSomethingToDo() {
    String user = getRequest().getSession().getAttribute("user");
    ShoppingCart cart = cartManager.findCartForUser(user);

    VarMap bizdata = new VarMap();
    bizdata.put("user", user);
   
    FormInstance fi = new FormInstance("cart.def.xml");
    fi.createBinding("cart.bnd.xml");
    fi.load(cart);
    fi.show("cart", bizdata);
    ....
}

I'm going by heart, so i apologize in advance for errors :)

How do i represent forms in javaflow:

var form = new Form("forms/artistOrder.xml");
form.showForm("artistLyricsPopUp1.xml",{"artistID":artistID,"artist_name":artist_name,"artist_info":artist_info,"track_lyrics":track_lyrics,"track_title":track_title,"userGlobal":userGlobal});
var model = form.getModel();
var bizData = {"next" : model.next, "delItem" : model.delItem, "quantity" : model.quantity}

See previous example.
and finally would I be correct in thinking that continuation is still represented as:

cocoon.sendPageAndWait("artistDetails2.xml",{"artistID":artistID});
sure :

VarMap bizdata = new VarMap();
bizdata.put("artistID", artistID);
sendPageAndWait("artistDetails2.xml",bizdata);



many thanks

Andrew

You're welcome.

Simone

--
Simone Gianni

Reply via email to