the theme for the form widget

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

the theme for the form widget

guo weizhan
Hi all,
 
We are creating the "theme" for the ofbiz widget form, why we create this? We found it's very difficultty to extend the current form widget, all the widget generation code is hard code in HtmlFormRenderer, we need to change this file if we want to add some function to the form, like ajax.
 
And yes, we have some ajax function in ofbiz now, but the code of HtmlFormRenderer with ajax is much harder for understanding. like the code: "if(ajaxEnabled)". In fact , we want to implement the dojo function in ofbiz without mess.
 
So we decide to extract the hard code is responsible for the html form generation  to the ftl files, like the struts2 does. If you know well about struts2, then you will also know the form theme we are creating.
 
Those ftl files is responsible for the html code generation, like text.ftl:
<input type="text"<#rt/>
 name="${rp.name?default("")?html}"<#rt/>
<#include "class.ftl" />
<#if rp.value?exists>
<#escape x as x?html> value="${rp.value}" </#escape> <#rt/>
</#if>
<#if rp.textSize?exists>
 size="${rp.textSize?html}"<#rt/>
</#if>
<#if rp.maxlength?exists>
 maxlength="${rp.maxlength?html}"<#rt/>
</#if>
<#if rp.textId?exists>
 id="${rp.textId?html}"<#rt/>
</#if>
<#if rp.event?exists && rp.action?exists>
 ${rp.event?html}="${rp.action?html}"<#rt/>
</#if>
<#if rp.clientAutocomplete?exists && !rp.clientAutocomplete>
  autocomplete="off"<#rt/>
</#if>
/>
Then, in the renderTextField method, we use the ftl file to generate the html text instand of the hard code.
 
Finally,we can have different themes like simple/text.ftl  ajax/text.ftl  and dojo/text.ftl. By setting the theme with code "theme=simple/ajax/dojo " , the corresponding theme file like text.ftl will be loaded. The attachment is the dojo theme capture.
 
If you are interested or have  any advises, we can discuss it in detail.  
 
 
Reply | Threaded
Open this post in threaded view
|

Re: the theme for the form widget

Anil Patel-3
+1
I have wanting to do this for long.

Sent from my iPhone

On Mar 1, 2009, at 10:30 AM, guo weizhan <[hidden email]> wrote:

> Hi all,
>
> We are creating the "theme" for the ofbiz widget form, why we create  
> this? We found it's very difficultty to extend the current form  
> widget, all the widget generation code is hard code in  
> HtmlFormRenderer, we need to change this file if we want to add some  
> function to the form, like ajax.
>
> And yes, we have some ajax function in ofbiz now, but the code of  
> HtmlFormRenderer with ajax is much harder for understanding. like  
> the code: "if(ajaxEnabled)". In fact , we want to implement the dojo  
> function in ofbiz without mess.
>
> So we decide to extract the hard code is responsible for the html  
> form generation  to the ftl files, like the struts2 does. If you  
> know well about struts2, then you will also know the form theme we  
> are creating.
>
> Those ftl files is responsible for the html code generation, like  
> text.ftl:
> <input type="text"<#rt/>
>  name="${rp.name?default("")?html}"<#rt/>
> <#include "class.ftl" />
> <#if rp.value?exists>
> <#escape x as x?html> value="${rp.value}" </#escape> <#rt/>
> </#if>
> <#if rp.textSize?exists>
>  size="${rp.textSize?html}"<#rt/>
> </#if>
> <#if rp.maxlength?exists>
>  maxlength="${rp.maxlength?html}"<#rt/>
> </#if>
> <#if rp.textId?exists>
>  id="${rp.textId?html}"<#rt/>
> </#if>
> <#if rp.event?exists && rp.action?exists>
>  ${rp.event?html}="${rp.action?html}"<#rt/>
> </#if>
> <#if rp.clientAutocomplete?exists && !rp.clientAutocomplete>
>   autocomplete="off"<#rt/>
> </#if>
> />
> Then, in the renderTextField method, we use the ftl file to generate  
> the html text instand of the hard code.
>
> Finally,we can have different themes like simple/text.ftl  ajax/
> text.ftl  and dojo/text.ftl. By setting the theme with code  
> "theme=simple/ajax/dojo " , the corresponding theme file like  
> text.ftl will be loaded. The attachment is the dojo theme capture.
>
> If you are interested or have  any advises, we can discuss it in  
> detail.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: the theme for the form widget

Adrian Crum-2
In reply to this post by guo weizhan

--- On Sun, 3/1/09, guo weizhan <[hidden email]> wrote:

> We are creating the "theme" for the ofbiz widget
> form, why we create this?
> We found it's very difficultty to extend the current
> form widget, all the
> widget generation code is hard code in HtmlFormRenderer, we
> need to change
> this file if we want to add some function to the form, like
> ajax.
>
> And yes, we have some ajax function in ofbiz now, but the
> code of
> HtmlFormRenderer with ajax is much harder for
> understanding.
> like the code: "if(ajaxEnabled)". In fact , we
> want to implement the dojo
> function in ofbiz without mess.

The reason the widget code checks to see if Ajax is enabled is because some users will have JavaScript disabled - in which case, plain HTML needs to be rendered.

-Adrian



     
Reply | Threaded
Open this post in threaded view
|

Re: the theme for the form widget

Bruno Busco
In reply to this post by guo weizhan
Hi Guo,
this looks interesting!

I think the best would be submitting a simple patch in a jira issue
when you have some ready.

-Bruno

2009/3/1 guo weizhan <[hidden email]>:

> Hi all,
>
> We are creating the "theme" for the ofbiz widget form, why we create this?
> We found it's very difficultty to extend the current form widget, all the
> widget generation code is hard code in HtmlFormRenderer, we need to change
> this file if we want to add some function to the form, like ajax.
>
> And yes, we have some ajax function in ofbiz now, but the code of
> HtmlFormRenderer with ajax is much harder for understanding.
> like the code: "if(ajaxEnabled)". In fact , we want to implement the dojo
> function in ofbiz without mess.
>
> So we decide to extract the hard code is responsible for the html form
> generation  to the ftl files, like the struts2 does. If you know well about
> struts2, then you will also know the form theme we are creating.
>
> Those ftl files is responsible for the html code generation, like text.ftl:
> <input type="text"<#rt/>
>  name="${rp.name?default("")?html}"<#rt/>
> <#include "class.ftl" />
> <#if rp.value?exists>
> <#escape x as x?html> value="${rp.value}" </#escape> <#rt/>
> </#if>
> <#if rp.textSize?exists>
>  size="${rp.textSize?html}"<#rt/>
> </#if>
> <#if rp.maxlength?exists>
>  maxlength="${rp.maxlength?html}"<#rt/>
> </#if>
> <#if rp.textId?exists>
>  id="${rp.textId?html}"<#rt/>
> </#if>
> <#if rp.event?exists && rp.action?exists>
>  ${rp.event?html}="${rp.action?html}"<#rt/>
> </#if>
> <#if rp.clientAutocomplete?exists && !rp.clientAutocomplete>
>   autocomplete="off"<#rt/>
> </#if>
> />
> Then, in the renderTextField method, we use the ftl file to generate the
> html text instand of the hard code.
>
> Finally,we can have different themes like simple/text.ftl  ajax/text.ftl
> and dojo/text.ftl. By setting the theme with code "theme=simple/ajax/dojo "
> , the corresponding theme file like text.ftl will be loaded. The attachment
> is the dojo theme capture.
>
> If you are interested or have  any advises, we can discuss it in detail.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: the theme for the form widget

guo weizhan
In reply to this post by Adrian Crum-2
I know what your mean, this is need to add more code to this class. if I
want to add dojo enabled, I have to add if(dojoEnable) and will let the
this class become hard to understand

2009/3/2 Adrian Crum <[hidden email]>

>
> --- On Sun, 3/1/09, guo weizhan <[hidden email]> wrote:
> > We are creating the "theme" for the ofbiz widget
> > form, why we create this?
> > We found it's very difficultty to extend the current
> > form widget, all the
> > widget generation code is hard code in HtmlFormRenderer, we
> > need to change
> > this file if we want to add some function to the form, like
> > ajax.
> >
> > And yes, we have some ajax function in ofbiz now, but the
> > code of
> > HtmlFormRenderer with ajax is much harder for
> > understanding.
> > like the code: "if(ajaxEnabled)". In fact , we
> > want to implement the dojo
> > function in ofbiz without mess.
>
> The reason the widget code checks to see if Ajax is enabled is because some
> users will have JavaScript disabled - in which case, plain HTML needs to be
> rendered.
>
> -Adrian
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: the theme for the form widget

guo weizhan
In reply to this post by Bruno Busco
that's a good idea, I will submit a jira issue later.

2009/3/2 Bruno Busco <[hidden email]>

> Hi Guo,
> this looks interesting!
>
> I think the best would be submitting a simple patch in a jira issue
> when you have some ready.
>
> -Bruno
>
> 2009/3/1 guo weizhan <[hidden email]>:
> > Hi all,
> >
> > We are creating the "theme" for the ofbiz widget form, why we create
> this?
> > We found it's very difficultty to extend the current form widget, all the
> > widget generation code is hard code in HtmlFormRenderer, we need to
> change
> > this file if we want to add some function to the form, like ajax.
> >
> > And yes, we have some ajax function in ofbiz now, but the code of
> > HtmlFormRenderer with ajax is much harder for understanding.
> > like the code: "if(ajaxEnabled)". In fact , we want to implement the dojo
> > function in ofbiz without mess.
> >
> > So we decide to extract the hard code is responsible for the html form
> > generation  to the ftl files, like the struts2 does. If you know well
> about
> > struts2, then you will also know the form theme we are creating.
> >
> > Those ftl files is responsible for the html code generation, like
> text.ftl:
> > <input type="text"<#rt/>
> >  name="${rp.name?default( <http://rp.name?default%28>"")?html}"<#rt/>
> > <#include "class.ftl" />
> > <#if rp.value?exists>
> > <#escape x as x?html> value="${rp.value}" </#escape> <#rt/>
> > </#if>
> > <#if rp.textSize?exists>
> >  size="${rp.textSize?html}"<#rt/>
> > </#if>
> > <#if rp.maxlength?exists>
> >  maxlength="${rp.maxlength?html}"<#rt/>
> > </#if>
> > <#if rp.textId?exists>
> >  id="${rp.textId?html}"<#rt/>
> > </#if>
> > <#if rp.event?exists && rp.action?exists>
> >  ${rp.event?html}="${rp.action?html}"<#rt/>
> > </#if>
> > <#if rp.clientAutocomplete?exists && !rp.clientAutocomplete>
> >   autocomplete="off"<#rt/>
> > </#if>
> > />
> > Then, in the renderTextField method, we use the ftl file to generate the
> > html text instand of the hard code.
> >
> > Finally,we can have different themes like simple/text.ftl  ajax/text.ftl
> > and dojo/text.ftl. By setting the theme with code
> "theme=simple/ajax/dojo "
> > , the corresponding theme file like text.ftl will be loaded. The
> attachment
> > is the dojo theme capture.
> >
> > If you are interested or have  any advises, we can discuss it in detail.
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: the theme for the form widget

Jacopo Cappellato-4
I have some code that I can share with my initial (incomplete)  
implementation of a form and screen widget renderers based on ftl  
macros:

the idea is that the html code is created by ftl macros, the macro  
calls are executed by the Screen/FormRenderers

I am working on it in my very limited spare time but I would be more  
than happy to share the code, especially if others will help me to  
complete the implementation.

Cheers,

Jacopo

On Mar 2, 2009, at 5:38 AM, guo weizhan wrote:

> that's a good idea, I will submit a jira issue later.
>
> 2009/3/2 Bruno Busco <[hidden email]>
>
>> Hi Guo,
>> this looks interesting!
>>
>> I think the best would be submitting a simple patch in a jira issue
>> when you have some ready.
>>
>> -Bruno
>>
>> 2009/3/1 guo weizhan <[hidden email]>:
>>> Hi all,
>>>
>>> We are creating the "theme" for the ofbiz widget form, why we create
>> this?
>>> We found it's very difficultty to extend the current form widget,  
>>> all the
>>> widget generation code is hard code in HtmlFormRenderer, we need to
>> change
>>> this file if we want to add some function to the form, like ajax.
>>>
>>> And yes, we have some ajax function in ofbiz now, but the code of
>>> HtmlFormRenderer with ajax is much harder for understanding.
>>> like the code: "if(ajaxEnabled)". In fact , we want to implement  
>>> the dojo
>>> function in ofbiz without mess.
>>>
>>> So we decide to extract the hard code is responsible for the html  
>>> form
>>> generation  to the ftl files, like the struts2 does. If you know  
>>> well
>> about
>>> struts2, then you will also know the form theme we are creating.
>>>
>>> Those ftl files is responsible for the html code generation, like
>> text.ftl:
>>> <input type="text"<#rt/>
>>> name="${rp.name?default( <http://rp.name?default%28>"")?html}"<#rt/>
>>> <#include "class.ftl" />
>>> <#if rp.value?exists>
>>> <#escape x as x?html> value="${rp.value}" </#escape> <#rt/>
>>> </#if>
>>> <#if rp.textSize?exists>
>>> size="${rp.textSize?html}"<#rt/>
>>> </#if>
>>> <#if rp.maxlength?exists>
>>> maxlength="${rp.maxlength?html}"<#rt/>
>>> </#if>
>>> <#if rp.textId?exists>
>>> id="${rp.textId?html}"<#rt/>
>>> </#if>
>>> <#if rp.event?exists && rp.action?exists>
>>> ${rp.event?html}="${rp.action?html}"<#rt/>
>>> </#if>
>>> <#if rp.clientAutocomplete?exists && !rp.clientAutocomplete>
>>>  autocomplete="off"<#rt/>
>>> </#if>
>>> />
>>> Then, in the renderTextField method, we use the ftl file to  
>>> generate the
>>> html text instand of the hard code.
>>>
>>> Finally,we can have different themes like simple/text.ftl  ajax/
>>> text.ftl
>>> and dojo/text.ftl. By setting the theme with code
>> "theme=simple/ajax/dojo "
>>> , the corresponding theme file like text.ftl will be loaded. The
>> attachment
>>> is the dojo theme capture.
>>>
>>> If you are interested or have  any advises, we can discuss it in  
>>> detail.
>>>
>>>
>>


smime.p7s (3K) Download Attachment