You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Abdullah Shaikh <ab...@gmail.com> on 2009/12/22 08:54:52 UTC

UI & Code separation

There is a discussion on Dev ML regarding UI & Code separation with subject
"Using Apache Wicket in Ofbiz presentation layer", I also had few thoughts
regarding this which I have already posted, reposting it here on User ML so
that more ideas can pour in.


When I was working on ecommerce I also found it difficult/troublesome to
change the UI, so regarding having separation of UI / Code in the
presentation layer, below are my thoughts, but I hadn't implemented them,
because I needed to complete the project and had no time for this.

What I feel is we can have all the data preparation in Groovy itself and
just the displaying part in FTL page, this would reduce the complexity in
FTL pages and would I guess provide the UI separation from code.

For example, currently FTL pages are some what like this,

if(this == that ) {
    <table>data goes here</table>
} else {
   <table>data goes here</table>
}

What we can do is, put this logic in groovy and let the ftl display the
data.

Groovy :
if(this == that) {
    context.put("data", data goes here);
} else {
    context.put("data", other data goes here);
}

FTL :

<table> data from context </table>

This way the FTL pages will be free of any logic and will just render the
data provided through context from Groovy.

If using this technique,

1) Every FTL page will require a Groovy file for data preparation logic
2) Any changes can be does easily as Groovy won't require server restart
3) Changes in the UI can be done easily as we just need to paste the new UI
code and get appropriate data from context and display it where ever you
require.

We can decide on a model for passing data to FTL pages, for example

Groovy :

data.put("userdetails", userdetails);
data.put("paymentsinfo" paymentinfo);
data.put"shoppingcart", shoppingcart);
context.put("data", data);

FTL :

<table data.get("userdetails")</table>
<table>data.get("paymentinfo", paymentinfo)</table>
<table>data.get("shoppingcart" shoppintcart);


This are just my thoughts on how can we separate UI from Code (display
logic), I haven't seen or used Apache Wicket so no idea about how that will
work or integrate in OFBiz.

But this approach wont require any new integration or any POC as Groovy &
FTL are already part of OFBiz.

Let me know your thoughts or anything that I am missing.

- Abdullah