Dev - Proposal for Ajax enhanced OFbiz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Dev - Proposal for Ajax enhanced OFbiz

Chris Juettner
Chris Juettner <[hidden email]> wrote:
 
If I may jump into this thread, let me describe to the group an AJAX
implementation I developed for a custom Ofbiz component we developed for
a client. 
This custom component was built on top of, and adheres to the Ofbiz
framework. There is of course some custom code to handle specific business
rule
functionality, but not a lot. 

There are two feature we wanted to provide to our customer that we
thought would be nice additions and make the UI a little richer. 

The first feature developed using AJAX concepts was form field
validations, configurable via XML to use either client-side validation
or server-side validation.  The validation can occur on a field by
field basis when an HTML event like onBlur or onChange occurs and/or
when the form is submitted.  DIVs are created on the fly to display a
message next to the form field that is getting validated.

The second feature developed using AJAX concepts was the "Google-like"
type-ahead functionality for text boxes that are created when 'Other'
is selected
from standard Ofbiz drop-down list boxes.  The data source used to
populate the type-ahead drop down lists comes from LDAP (in our case Active
Directory). 

I had no previous experience with AJAX before I started these features,
so I relied heavily on the Ajax In Action book, which was a huge help. 
The impact to
core Ofbiz was almost no existent.  There was some code I needed to add
to the HtmlFormRenderer renderDropDownField method for new CSS styles.
Because the MVC pattern is followed by Ofbiz, I just created new
services to call the Java methods I wanted to execute and once the
XMLHttpRequest object's
open was called the controller stepped in to execute the desired
service or method. The methods return XML which is then processed on the
client side. 
Client-side techniques used were JSON, DHTML, and DOM written in
standard JavaScript modified for my needs from various examples around the
web.

As an example of the form widget impact, for field validations I
created a new style and just appended it to the existing widget style to
provide the look I wanted.
I also took advantage of  the event/action properties to fire a
server-side AJAX call.
For example:
<field name="field" id-name="theField" title="${uiLabelMap.theField}"
widget-style="inputBox required" event="onChange"
action="validateOnField(this.form,this)">

These AJAX features are probably fairly simplistic, but they satisfy a
need in a straightforward way that is easy to maintain and hardly
affects core Ofbiz. 

To me, AJAX is a viable technique when used to enhance functionality. 
I'm not sure what happens when overuse creeps into the development
process.

Chris Juettner
Integral Business Solutions
 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Andrew Sykes
Sent: Thursday, June 15, 2006 3:48 AM
To: OFBiz Project Development Discussion
Subject: Re: [OFBiz] Dev - Proposal for Ajax enhanced OFbiz

I think this approach has precedent.

If I remember correctly from the conference videos, Brett Palmer's
entity engine stuff was handled in this way...

- Andrew

On Thu, 2006-06-15 at 09:43 +0200, David Welton wrote:

> One way of handling big integrations from a new person might be:
>
> 1) "This is how I'm going to build it" - the new guy - so that people
> know what's going to happen, and don't have as much room for objection
> after he's dedicated a lot of time to the project.
>
> 2) Build it - so that people can see what it looks like and how it
> works. More action, less talk:-)
>
> 3) Fine tune as needs be. In this case it's definitely a project that
> requires both specialized OFBiz knowledge, as well as Ajax/javascript
> knowledge.
>
> 4) Commit it - existing committer who agrees to dedicate some time to
> review and understand the new code.
>
> 5) Cycle through steps 2-4 until people are comfortable with the new
> guy and committ access is handed out.
>
> Just a suggestion though - I don't think it's common practice to hand
> out commit access on the hope that good things will come of it, but
> for big projects, you also have to agree to dedicate some time to them
> beyond just looking at a patch now and then.
>
--
Kind Regards
Andrew Sykes
Sykes Development Ltd
http://www.sykesdevelopment.com


_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev




 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Dev - Proposal for Ajax enhanced OFbiz

David E. Jones

Thanks Chris, this is a nice example of AJAX in action... I'm glad to hear things are moving along over at Integral!

-David


Chris Juettner wrote:

> */Chris Juettner <[hidden email]>/* wrote:
>  
> If I may jump into this thread, let me describe to the group an AJAX
> implementation I developed for a custom Ofbiz component we developed for
> a client.
> This custom component was built on top of, and adheres to the Ofbiz
> framework. There is of course some custom code to handle specific business
> rule
> functionality, but not a lot.
>
> There are two feature we wanted to provide to our customer that we
> thought would be nice additions and make the UI a little richer.
>
> The first feature developed using AJAX concepts was form field
> validations, configurable via XML to use either client-side validation
> or server-side validation.  The validation can occur on a field by
> field basis when an HTML event like onBlur or onChange occurs and/or
> when the form is submitted.  DIVs are created on the fly to display a
> message next to the form field that is getting validated.
>
> The second feature developed using AJAX concepts was the "Google-like"
> type-ahead functionality for text boxes that are created when 'Other'
> is selected
> from standard Ofbiz drop-down list boxes.  The data source used to
> populate the type-ahead drop down lists comes from LDAP (in our case Active
> Directory).
>
> I had no previous experience with AJAX before I started these features,
> so I relied heavily on the Ajax In Action book, which was a huge help.
> The impact to
> core Ofbiz was almost no existent.  There was some code I needed to add
> to the HtmlFormRenderer renderDropDownField method for new CSS styles.
> Because the MVC pattern is followed by Ofbiz, I just created new
> services to call the Java methods I wanted to execute and once the
> XMLHttpRequest object's
> open was called the controller stepped in to execute the desired
> service or method. The methods return XML which is then processed on the
> client side.
> Client-side techniques used were JSON, DHTML, and DOM written in
> standard JavaScript modified for my needs from various examples around the
> web.
>
> As an example of the form widget impact, for field validations I
> created a new style and just appended it to the existing widget style to
> provide the look I wanted.
> I also took advantage of  the event/action properties to fire a
> server-side AJAX call.
> For example:
> <field name="field" id-name="theField" title="${uiLabelMap.theField}"
> widget-style="inputBox required" event="onChange"
> action="validateOnField(this.form,this)">
>
> These AJAX features are probably fairly simplistic, but they satisfy a
> need in a straightforward way that is easy to maintain and hardly
> affects core Ofbiz.
>
> To me, AJAX is a viable technique when used to enhance functionality.
> I'm not sure what happens when overuse creeps into the development
> process.
>
> Chris Juettner
> Integral Business Solutions
>  
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of Andrew Sykes
> Sent: Thursday, June 15, 2006 3:48 AM
> To: OFBiz Project Development Discussion
> Subject: Re: [OFBiz] Dev - Proposal for Ajax enhanced OFbiz
>
> I think this approach has precedent.
>
> If I remember correctly from the conference videos, Brett Palmer's
> entity engine stuff was handled in this way...
>
> - Andrew
>
> On Thu, 2006-06-15 at 09:43 +0200, David Welton wrote:
>  > One way of handling big integrations from a new person might be:
>  >
>  > 1) "This is how I'm going to build it" - the new guy - so that people
>  > know what's going to happen, and don't have as much room for objection
>  > after he's dedicated a lot of time to the project.
>  >
>  > 2) Build it - so that people can see what it looks like and how it
>  > works. More action, less talk:-)
>  >
>  > 3) Fine tune as needs be. In this case it's definitely a project that
>  > requires both specialized OFBiz knowledge, as well as Ajax/javascript
>  > knowledge.
>  >
>  > 4) Commit it - existing committer who agrees to dedicate some time to
>  > review and understand the new code.
>  >
>  > 5) Cycle through steps 2-4 until people are comfortable with the new
>  > guy and committ access is handed out.
>  >
>  > Just a suggestion though - I don't think it's common practice to hand
>  > out commit access on the hope that good things will come of it, but
>  > for big projects, you also have to agree to dedicate some time to them
>  > beyond just looking at a patch now and then.
>  >
> --
> Kind Regards
> Andrew Sykes
> Sykes Development Ltd
> http://www.sykesdevelopment.com
>
>
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>
>
>
>
> ------------------------------------------------------------------------
>
>  
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Dev - Proposal for Ajax enhanced OFbiz

Ruth Hoffman
Hi Chris:
Thanks for this info. Wonder if you wouldn't mind clarifying a bit?
Is this how it works:
1) on page load: - load a Javascript function to initiate server calls
(XMLHttpRequest) & handle call back
2) on client side: - onclick or other event ->send a request to server
(XMLHttpRequest)  -> through the OFBiz controller (~/control/xxx -> to a
service interface -> to a Java method
3) from the server side: send an (XMLHttpRequest/response)  message
directly to the browser
4) repeat, but always send the request through the OFBiz controller?

BTW, IMHO the "Ajax in Action" book is the best I've seen so far on this
topic.

TIA
Ruth
David E Jones wrote:

>Thanks Chris, this is a nice example of AJAX in action... I'm glad to hear things are moving along over at Integral!
>
>-David
>
>
>Chris Juettner wrote:
>  
>
>>*/Chris Juettner <[hidden email]>/* wrote:
>>
>>If I may jump into this thread, let me describe to the group an AJAX
>>implementation I developed for a custom Ofbiz component we developed for
>>a client.
>>This custom component was built on top of, and adheres to the Ofbiz
>>framework. There is of course some custom code to handle specific business
>>rule
>>functionality, but not a lot.
>>
>>There are two feature we wanted to provide to our customer that we
>>thought would be nice additions and make the UI a little richer.
>>
>>The first feature developed using AJAX concepts was form field
>>validations, configurable via XML to use either client-side validation
>>or server-side validation.  The validation can occur on a field by
>>field basis when an HTML event like onBlur or onChange occurs and/or
>>when the form is submitted.  DIVs are created on the fly to display a
>>message next to the form field that is getting validated.
>>
>>The second feature developed using AJAX concepts was the "Google-like"
>>type-ahead functionality for text boxes that are created when 'Other'
>>is selected
>>from standard Ofbiz drop-down list boxes.  The data source used to
>>populate the type-ahead drop down lists comes from LDAP (in our case Active
>>Directory).
>>
>>I had no previous experience with AJAX before I started these features,
>>so I relied heavily on the Ajax In Action book, which was a huge help.
>>The impact to
>>core Ofbiz was almost no existent.  There was some code I needed to add
>>to the HtmlFormRenderer renderDropDownField method for new CSS styles.
>>Because the MVC pattern is followed by Ofbiz, I just created new
>>services to call the Java methods I wanted to execute and once the
>>XMLHttpRequest object's
>>open was called the controller stepped in to execute the desired
>>service or method. The methods return XML which is then processed on the
>>client side.
>>Client-side techniques used were JSON, DHTML, and DOM written in
>>standard JavaScript modified for my needs from various examples around the
>>web.
>>
>>As an example of the form widget impact, for field validations I
>>created a new style and just appended it to the existing widget style to
>>provide the look I wanted.
>>I also took advantage of  the event/action properties to fire a
>>server-side AJAX call.
>>For example:
>><field name="field" id-name="theField" title="${uiLabelMap.theField}"
>>widget-style="inputBox required" event="onChange"
>>action="validateOnField(this.form,this)">
>>
>>These AJAX features are probably fairly simplistic, but they satisfy a
>>need in a straightforward way that is easy to maintain and hardly
>>affects core Ofbiz.
>>
>>To me, AJAX is a viable technique when used to enhance functionality.
>>I'm not sure what happens when overuse creeps into the development
>>process.
>>
>>Chris Juettner
>>Integral Business Solutions
>>
>>
>>-----Original Message-----
>>From: [hidden email] [mailto:[hidden email]]
>>On Behalf Of Andrew Sykes
>>Sent: Thursday, June 15, 2006 3:48 AM
>>To: OFBiz Project Development Discussion
>>Subject: Re: [OFBiz] Dev - Proposal for Ajax enhanced OFbiz
>>
>>I think this approach has precedent.
>>
>>If I remember correctly from the conference videos, Brett Palmer's
>>entity engine stuff was handled in this way...
>>
>>- Andrew
>>
>>On Thu, 2006-06-15 at 09:43 +0200, David Welton wrote:
>> > One way of handling big integrations from a new person might be:
>> >
>> > 1) "This is how I'm going to build it" - the new guy - so that people
>> > know what's going to happen, and don't have as much room for objection
>> > after he's dedicated a lot of time to the project.
>> >
>> > 2) Build it - so that people can see what it looks like and how it
>> > works. More action, less talk:-)
>> >
>> > 3) Fine tune as needs be. In this case it's definitely a project that
>> > requires both specialized OFBiz knowledge, as well as Ajax/javascript
>> > knowledge.
>> >
>> > 4) Commit it - existing committer who agrees to dedicate some time to
>> > review and understand the new code.
>> >
>> > 5) Cycle through steps 2-4 until people are comfortable with the new
>> > guy and committ access is handed out.
>> >
>> > Just a suggestion though - I don't think it's common practice to hand
>> > out commit access on the hope that good things will come of it, but
>> > for big projects, you also have to agree to dedicate some time to them
>> > beyond just looking at a patch now and then.
>> >
>>--
>>Kind Regards
>>Andrew Sykes
>>Sykes Development Ltd
>>http://www.sykesdevelopment.com
>>
>>
>>_______________________________________________
>>Dev mailing list
>>[hidden email]
>>http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>
>>_______________________________________________
>>Dev mailing list
>>[hidden email]
>>http://lists.ofbiz.org/mailman/listinfo/dev
>>    
>>
>
>_______________________________________________
>Dev mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/dev
>
>  
>
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Dev - Proposal for Ajax enhanced OFbiz

Chris Juettner
Ruth, you pretty much have it.  Let me see if I can explain a little more.. 
 
When the page loads some javascript code (JSON) executes which creates an AJAX object that sets up the XMLHttpRequest and callbacks.  This object then call the server to load an XML file with the form validation declaratives that are used later when a client-side validation event is called. In my case all my AJAX server calls return XML which is processed on the client-side using DOM methods.  You could return text also.
 
On the client side, as my previous example shows, based on some event, execute a javascript function. The responsibility of this function is to extract from the form validation XML declarative the Ofbiz service or simple method to execute. An AJAX call is made as a POST and then the Ofbiz controller makes whatever type of service engine call you want and then sends the response object back to the client for processing. 
 
For my AJAX form validation, here is an example of the XML used to declare custom server-side simple method or service.  Hope this helps.
 
<field id="groupName" required="true" rule="validateProjectName" tier="server" returnFocus="true"></field>
 
 
Chris Juettner
Integral Business Solutions.
 
 

Ruth Hoffman <[hidden email]> wrote:
Hi Chris:
Thanks for this info. Wonder if you wouldn't mind clarifying a bit?
Is this how it works:
1) on page load: - load a Javascript function to initiate server calls
(XMLHttpRequest) & handle call back
2) on client side: - onclick or other event ->send a request to server
(XMLHttpRequest) -> through the OFBiz controller (~/control/xxx -> to a
service interface -> to a Java method
3) from the server side: send an (XMLHttpRequest/response) message
directly to the browser
4) repeat, but always send the request through the OFBiz controller?

BTW, IMHO the "Ajax in Action" book is the best I've seen so far on this
topic.

TIA
Ruth
David E Jones wrote:

>Thanks Chris, this is a nice example of AJAX in action... I'm glad to hear things are moving along over at Integral!
>
>-David
>
>
>Chris Juettner wrote:
>
>
>>*/Chris Juettner /* wrote:
>>
>>If I may jump into this thread, let me describe to the group an AJAX
>>implementation I developed for a custom Ofbiz component we developed for
>>a client.
>>This custom component was built on top of, and adheres to the Ofbiz
>>framework. There is of course some custom code to handle specific business
>>rule
>>functionality, but not a lot.
>>
>>There are two feature we wanted to provide to our customer that we
>>thought would be nice additions and make the UI a little richer.
>>
>>The first feature developed using AJAX concepts was form field
>>validations, configurable via XML to use either client-side validation
>>or server-side validation. The validation can occur on a field by
>>field basis when an HTML event like onBlur or onChange occurs and/or
>>when the form is submitted. DIVs are created on the fly to display a
>>message next to the form field that is getting validated.
>>
>>The second feature developed using AJAX concepts was the "Google-like"
>>type-ahead functionality for text boxes that are created when 'Other'
>>is selected
>>from standard Ofbiz drop-down list boxes. The data source used to
>>populate the type-ahead drop down lists comes from LDAP (in our case Active
>>Directory).
>>
>>I had no previous experience with AJAX before I started these features,
>>so I relied heavily on the Ajax In Action book, which was a huge help.
>>The impact to
>>core Ofbiz was almost no existent. There was some code I needed to add
>>to the HtmlFormRenderer renderDropDownField method for new CSS styles.
>>Because the MVC pattern is followed by Ofbiz, I just created new
>>services to call the Java methods I wanted to execute and once the
>>XMLHttpRequest object's
>>open was called the controller stepped in to execute the desired
>>service or method. The methods return XML which is then processed on the
>>client side.
>>Client-side techniques used were JSON, DHTML, and DOM written in
>>standard JavaScript modified for my needs from various examples around the
>>web.
>>
>>As an example of the form widget impact, for field validations I
>>created a new style and just appended it to the existing widget style to
>>provide the look I wanted.
>>I also took advantage of the event/action properties to fire a
>>server-side AJAX call.
>>For example:
>>>>widget-style="inputBox required" event="onChange"
>>action="validateOnField(this.form,this)">
>>
>>These AJAX features are probably fairly simplistic, but they satisfy a
>>need in a straightforward way that is easy to maintain and hardly
>>affects core Ofbiz.
>>
>>To me, AJAX is a viable technique when used to enhance functionality.
>>I'm not sure what happens when overuse creeps into the development
>>process.
>>
>>Chris Juettner
>>Integral Business Solutions
>>
>>
>>-----Original Message-----
>>From: [hidden email] [mailto:[hidden email]]
>>On Behalf Of Andrew Sykes
>>Sent: Thursday, June 15, 2006 3:48 AM
>>To: OFBiz Project Development Discussion
>>Subject: Re: [OFBiz] Dev - Proposal for Ajax enhanced OFbiz
>>
>>I think this approach has precedent.
>>
>>If I remember correctly from the conference videos, Brett Palmer's
>>entity engine stuff was handled in this way...
>>
>>- Andrew
>>
>>On Thu, 2006-06-15 at 09:43 +0200, David Welton wrote:
>> > One way of handling big integrations from a new person might be:
>> >
>> > 1) "This is how I'm going to build it" - the new guy - so that people
>> > know what's going to happen, and don't have as much room for objection
>> > after he's dedicated a lot of time to the project.
>> >
>> > 2) Build it - so that people can see what it looks like and how it
>> > works. More action, less talk:-)
>> >
>> > 3) Fine tune as needs be. In this case it's definitely a project that
>> > requires both specialized OFBiz knowledge, as well as Ajax/javascript
>> > knowledge.
>> >
>> > 4) Commit it - existing committer who agrees to dedicate some time to
>> > review and understand the new code.
>> >
>> > 5) Cycle through steps 2-4 until people are comfortable with the new
>> > guy and committ access is handed out.
>> >
>> > Just a suggestion though - I don't think it's common practice to hand
>> > out commit access on the hope that good things will come of it, but
>> > for big projects, you also have to agree to dedicate some time to them
>> > beyond just looking at a patch now and then.
>> >
>>--
>>Kind Regards
>>Andrew Sykes
>>Sykes Development Ltd
>>http://www.sykesdevelopment.com
>>
>>
>>_______________________________________________
>>Dev mailing list
>>[hidden email]
>>http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>
>>_______________________________________________
>>Dev mailing list
>>[hidden email]
>>http://lists.ofbiz.org/mailman/listinfo/dev
>>
>>
>
>_______________________________________________
>Dev mailing list
>[hidden email]
>http://lists.ofbiz.org/mailman/listinfo/dev
>
>
>

_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev


 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev