You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Anil Patel <to...@gmail.com> on 2007/03/20 19:55:46 UTC

Embed Javascript in screens rendered using Screen/Form Widgets

Hi,
I am looking into using Ajax/JSON for moving data between UI and Server. If
the Screen uses form widgets then how/where do we put the javascript code
that needs to go with html form. I know we can do this in forms done in ftl,
but that needs lot of coding.

Any Ideas on what my options are here.

What If I create a file that has all the javascript that form will need and
add it to screen like in this example. But this breaks some basic design
rules.

    <screen name="EditGlJournalEntry">
        <section>
            <actions>
                <set field="targetAction"
value="lightCreateGlJournalEntry"/>
                <set field="titleProperty" value="AcctgEditGlJournalEntry"/>
                <set field="tabButtonItem" value="EditGlJournalEntry"/>
                <set field="labelTitleProperty"
value="AcctgEditGlJournalEntry"/>
                <entity-condition entity-name="GlAccount"
list-name="entityList" use-cache="true" >
                    <condition-expr field-name="glAccountId"
operator="greater" value="0" />
                </entity-condition>
            </actions>
            <widgets>
                <container>
                        <platform-specific>
                            <html><html-template
location="component://accounting/webapp/accounting/chartofaccounts/GlAccountForms.js.ftl"/></html>
                        </platform-specific>
                    <include-form name="EditGlJournalEntry"
location="component://accounting/webapp/accounting/chartofaccounts/GlAccountForms.xml"/>
                </container>
            </widgets>
        </section>
    </screen>



Regards
Anil Patel

Re: Embed Javascript in screens rendered using Screen/Form Widgets

Posted by Jonathon -- Improov <jo...@improov.com>.
Adrian,

+1

Yes, this should be better.

Jonathon

Adrian Crum wrote:
> Why not put the javascript in a separate file and load it via 
> layoutSettings.javaScripts[] in the <actions> section?
> 
> 
> David E. Jones wrote:
> 
>>
>> What basic design rule does it break?
>>
>> IMO this is fine, we have to keep the javascript somewhere, and an  
>> ftl file like that is probably as good as any place.
>>
>> -David
>>
>>
>> On Mar 20, 2007, at 12:55 PM, Anil Patel wrote:
>>
>>> Hi,
>>> I am looking into using Ajax/JSON for moving data between UI and  
>>> Server. If
>>> the Screen uses form widgets then how/where do we put the  javascript 
>>> code
>>> that needs to go with html form. I know we can do this in forms  done 
>>> in ftl,
>>> but that needs lot of coding.
>>>
>>> Any Ideas on what my options are here.
>>>
>>> What If I create a file that has all the javascript that form will  
>>> need and
>>> add it to screen like in this example. But this breaks some basic  
>>> design
>>> rules.
>>>
>>>    <screen name="EditGlJournalEntry">
>>>        <section>
>>>            <actions>
>>>                <set field="targetAction"
>>> value="lightCreateGlJournalEntry"/>
>>>                <set field="titleProperty"  
>>> value="AcctgEditGlJournalEntry"/>
>>>                <set field="tabButtonItem" value="EditGlJournalEntry"/>
>>>                <set field="labelTitleProperty"
>>> value="AcctgEditGlJournalEntry"/>
>>>                <entity-condition entity-name="GlAccount"
>>> list-name="entityList" use-cache="true" >
>>>                    <condition-expr field-name="glAccountId"
>>> operator="greater" value="0" />
>>>                </entity-condition>
>>>            </actions>
>>>            <widgets>
>>>                <container>
>>>                        <platform-specific>
>>>                            <html><html-template
>>> location="component://accounting/webapp/accounting/chartofaccounts/ 
>>> GlAccountForms.js.ftl"/></html>
>>>                        </platform-specific>
>>>                    <include-form name="EditGlJournalEntry"
>>> location="component://accounting/webapp/accounting/chartofaccounts/ 
>>> GlAccountForms.xml"/>
>>>                </container>
>>>            </widgets>
>>>        </section>
>>>    </screen>
>>>
>>>
>>>
>>> Regards
>>> Anil Patel
>>
>>
> 
> 


Re: Embed Javascript in screens rendered using Screen/Form Widgets

Posted by Adrian Crum <ad...@hlmksw.com>.
Why not put the javascript in a separate file and load it via 
layoutSettings.javaScripts[] in the <actions> section?


David E. Jones wrote:

> 
> What basic design rule does it break?
> 
> IMO this is fine, we have to keep the javascript somewhere, and an  ftl 
> file like that is probably as good as any place.
> 
> -David
> 
> 
> On Mar 20, 2007, at 12:55 PM, Anil Patel wrote:
> 
>> Hi,
>> I am looking into using Ajax/JSON for moving data between UI and  
>> Server. If
>> the Screen uses form widgets then how/where do we put the  javascript 
>> code
>> that needs to go with html form. I know we can do this in forms  done 
>> in ftl,
>> but that needs lot of coding.
>>
>> Any Ideas on what my options are here.
>>
>> What If I create a file that has all the javascript that form will  
>> need and
>> add it to screen like in this example. But this breaks some basic  design
>> rules.
>>
>>    <screen name="EditGlJournalEntry">
>>        <section>
>>            <actions>
>>                <set field="targetAction"
>> value="lightCreateGlJournalEntry"/>
>>                <set field="titleProperty"  
>> value="AcctgEditGlJournalEntry"/>
>>                <set field="tabButtonItem" value="EditGlJournalEntry"/>
>>                <set field="labelTitleProperty"
>> value="AcctgEditGlJournalEntry"/>
>>                <entity-condition entity-name="GlAccount"
>> list-name="entityList" use-cache="true" >
>>                    <condition-expr field-name="glAccountId"
>> operator="greater" value="0" />
>>                </entity-condition>
>>            </actions>
>>            <widgets>
>>                <container>
>>                        <platform-specific>
>>                            <html><html-template
>> location="component://accounting/webapp/accounting/chartofaccounts/ 
>> GlAccountForms.js.ftl"/></html>
>>                        </platform-specific>
>>                    <include-form name="EditGlJournalEntry"
>> location="component://accounting/webapp/accounting/chartofaccounts/ 
>> GlAccountForms.xml"/>
>>                </container>
>>            </widgets>
>>        </section>
>>    </screen>
>>
>>
>>
>> Regards
>> Anil Patel
> 
> 

Re: Embed Javascript in screens rendered using Screen/Form Widgets

Posted by Jonathon -- Improov <jo...@improov.com>.
Anil,

That's certainly how I do it. Some javascript functions are tightly coupled to a particular form 
widget, so unless you can embed the javascript into the form widget itself, the next best thing 
would be to place it in the screen widget (via a reference to an FTL file) like what you did.

Jonathon

Anil Patel wrote:
> I am worried about adding dependency on a External file,
> GlAccountForms.xmlwill depend on
> GlAccountForms.js.ftl in order to work. Code in GlAccountForms.js.ftl will
> have to know and depend on field and form name defined 
> GlAccountForms.xmlfile.
> 
> If this type of dependency is ok then I'll take this route.
> 
> Regards
> Anil Patel
> 
> 
> On 3/20/07, David E. Jones <jo...@hotwaxmedia.com> wrote:
>>
>>
>> What basic design rule does it break?
>>
>> IMO this is fine, we have to keep the javascript somewhere, and an
>> ftl file like that is probably as good as any place.
>>
>> -David
>>
>>
>> On Mar 20, 2007, at 12:55 PM, Anil Patel wrote:
>>
>> > Hi,
>> > I am looking into using Ajax/JSON for moving data between UI and
>> > Server. If
>> > the Screen uses form widgets then how/where do we put the
>> > javascript code
>> > that needs to go with html form. I know we can do this in forms
>> > done in ftl,
>> > but that needs lot of coding.
>> >
>> > Any Ideas on what my options are here.
>> >
>> > What If I create a file that has all the javascript that form will
>> > need and
>> > add it to screen like in this example. But this breaks some basic
>> > design
>> > rules.
>> >
>> >    <screen name="EditGlJournalEntry">
>> >        <section>
>> >            <actions>
>> >                <set field="targetAction"
>> > value="lightCreateGlJournalEntry"/>
>> >                <set field="titleProperty"
>> > value="AcctgEditGlJournalEntry"/>
>> >                <set field="tabButtonItem" value="EditGlJournalEntry"/>
>> >                <set field="labelTitleProperty"
>> > value="AcctgEditGlJournalEntry"/>
>> >                <entity-condition entity-name="GlAccount"
>> > list-name="entityList" use-cache="true" >
>> >                    <condition-expr field-name="glAccountId"
>> > operator="greater" value="0" />
>> >                </entity-condition>
>> >            </actions>
>> >            <widgets>
>> >                <container>
>> >                        <platform-specific>
>> >                            <html><html-template
>> > location="component://accounting/webapp/accounting/chartofaccounts/
>> > GlAccountForms.js.ftl"/></html>
>> >                        </platform-specific>
>> >                    <include-form name="EditGlJournalEntry"
>> > location="component://accounting/webapp/accounting/chartofaccounts/
>> > GlAccountForms.xml"/>
>> >                </container>
>> >            </widgets>
>> >        </section>
>> >    </screen>
>> >
>> >
>> >
>> > Regards
>> > Anil Patel
>>
>>
>>
> 
> 
> ------------------------------------------------------------------------
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.15/728 - Release Date: 3/20/2007 8:07 AM


Re: Embed Javascript in screens rendered using Screen/Form Widgets

Posted by Anil Patel <to...@gmail.com>.
I am worried about adding dependency on a External file,
GlAccountForms.xmlwill depend on
GlAccountForms.js.ftl in order to work. Code in GlAccountForms.js.ftl will
have to know and depend on field and form name defined GlAccountForms.xmlfile.

If this type of dependency is ok then I'll take this route.

Regards
Anil Patel


On 3/20/07, David E. Jones <jo...@hotwaxmedia.com> wrote:
>
>
> What basic design rule does it break?
>
> IMO this is fine, we have to keep the javascript somewhere, and an
> ftl file like that is probably as good as any place.
>
> -David
>
>
> On Mar 20, 2007, at 12:55 PM, Anil Patel wrote:
>
> > Hi,
> > I am looking into using Ajax/JSON for moving data between UI and
> > Server. If
> > the Screen uses form widgets then how/where do we put the
> > javascript code
> > that needs to go with html form. I know we can do this in forms
> > done in ftl,
> > but that needs lot of coding.
> >
> > Any Ideas on what my options are here.
> >
> > What If I create a file that has all the javascript that form will
> > need and
> > add it to screen like in this example. But this breaks some basic
> > design
> > rules.
> >
> >    <screen name="EditGlJournalEntry">
> >        <section>
> >            <actions>
> >                <set field="targetAction"
> > value="lightCreateGlJournalEntry"/>
> >                <set field="titleProperty"
> > value="AcctgEditGlJournalEntry"/>
> >                <set field="tabButtonItem" value="EditGlJournalEntry"/>
> >                <set field="labelTitleProperty"
> > value="AcctgEditGlJournalEntry"/>
> >                <entity-condition entity-name="GlAccount"
> > list-name="entityList" use-cache="true" >
> >                    <condition-expr field-name="glAccountId"
> > operator="greater" value="0" />
> >                </entity-condition>
> >            </actions>
> >            <widgets>
> >                <container>
> >                        <platform-specific>
> >                            <html><html-template
> > location="component://accounting/webapp/accounting/chartofaccounts/
> > GlAccountForms.js.ftl"/></html>
> >                        </platform-specific>
> >                    <include-form name="EditGlJournalEntry"
> > location="component://accounting/webapp/accounting/chartofaccounts/
> > GlAccountForms.xml"/>
> >                </container>
> >            </widgets>
> >        </section>
> >    </screen>
> >
> >
> >
> > Regards
> > Anil Patel
>
>
>

Re: Embed Javascript in screens rendered using Screen/Form Widgets

Posted by "David E. Jones" <jo...@hotwaxmedia.com>.
What basic design rule does it break?

IMO this is fine, we have to keep the javascript somewhere, and an  
ftl file like that is probably as good as any place.

-David


On Mar 20, 2007, at 12:55 PM, Anil Patel wrote:

> Hi,
> I am looking into using Ajax/JSON for moving data between UI and  
> Server. If
> the Screen uses form widgets then how/where do we put the  
> javascript code
> that needs to go with html form. I know we can do this in forms  
> done in ftl,
> but that needs lot of coding.
>
> Any Ideas on what my options are here.
>
> What If I create a file that has all the javascript that form will  
> need and
> add it to screen like in this example. But this breaks some basic  
> design
> rules.
>
>    <screen name="EditGlJournalEntry">
>        <section>
>            <actions>
>                <set field="targetAction"
> value="lightCreateGlJournalEntry"/>
>                <set field="titleProperty"  
> value="AcctgEditGlJournalEntry"/>
>                <set field="tabButtonItem" value="EditGlJournalEntry"/>
>                <set field="labelTitleProperty"
> value="AcctgEditGlJournalEntry"/>
>                <entity-condition entity-name="GlAccount"
> list-name="entityList" use-cache="true" >
>                    <condition-expr field-name="glAccountId"
> operator="greater" value="0" />
>                </entity-condition>
>            </actions>
>            <widgets>
>                <container>
>                        <platform-specific>
>                            <html><html-template
> location="component://accounting/webapp/accounting/chartofaccounts/ 
> GlAccountForms.js.ftl"/></html>
>                        </platform-specific>
>                    <include-form name="EditGlJournalEntry"
> location="component://accounting/webapp/accounting/chartofaccounts/ 
> GlAccountForms.xml"/>
>                </container>
>            </widgets>
>        </section>
>    </screen>
>
>
>
> Regards
> Anil Patel