How to receive in a service a variable list of fields from a form (and iterate on it)?

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

How to receive in a service a variable list of fields from a form (and iterate on it)?

Bruno Busco
Hi devs,
I need your help.

I am trying to complete the Portal/Portlet stuff adding the possibility to
set some attributes specific to a Portlet instance.

The idea is that when a portlet is defined, a form is defined also and
linked in the PortalPortlet entity with something similar to this:
    <PortalPortlet portalPortletId="LOGIN" portletName="Login"
description="Login form"
                   screenName="loginPortlet"
screenLocation="component://common/widget/PortletScreens.xml"
                   editFormName="LoginPortletEdit"
editFormLocation="component://common/widget/PortletEditForms.xml" />

The form is needed to edit a particular Portlet instance attributes. This
extends from a common frame defined in the framework like this:
    <form name="CommonPortletEdit" type="single"
target="setPortalPortletAttributes" title=""
default-map-name="PortalPortletAttributeMap">
        <field name="portalPageId"><hidden/></field>
        <field name="portalPortletId"><hidden/></field>
        <field name="portletSeqId"><hidden/></field>
        <field name="submitButton" title="${uiLabelMap.CommonEdit}"><submit
button-type="button"/></field>
    </form>

Using this method an example of a specific portlet attribute editing form
could be:
    <form name="LoginPortletEdit" extends="CommonPortletEdit"
extends-resource="component://common/widget/CommonForms.xml">
        <field name="ItemsToShow">
            <drop-down allow-empty="false">
                <option key="5"/>
                <option key="15"/>
                <option key="20"/>
                <option key="25"/>
                <option key="30"/>
                <option key="35"/>
            </drop-down>
        </field>
    </form>

In this example I supposed that the portlet has an attribute "ItemsToShow"
that tells the portlet how many items to show.

When the user submits one of the portlet attributes editing forms, the
setPortalPortletAttributes service is triggered.

My problem is now how to make this service able to retrieve from the
submitted form the list of fields so that the Attribute entities can be
created/updated.

Is there an example of this in OFBiz?
How can the service receive a map of fields that is not constant to iterate
on?

Many thanks for your help!
-Bruno
Reply | Threaded
Open this post in threaded view
|

Re: How to receive in a service a variable list of fields from a form (and iterate on it)?

BJ Freeman
in ofbiz forms are fixed, like most you see in widgets and ftls.
you have a entity and/or context that stores the info, like in maps.
you then use the widget/ftl form to display the data in the entity or
context.
the ItemsToShow would be a map.
you would then iterate the map. you can see many examples of this.
you then set a field on the selection
here is an example you can find it in the blllingaccountsform.xml
    <form name="ListBillingAccounts" type="list"
list-name="billingAccounts" paginate-target="FindBillingAccount"
default-entity-name="BillingAccount"
        odd-row-style="alternate-row" default-table-style="basic-table
hover-bar">
        <field name="billingAccountId" widget-style="buttontext">
            <hyperlink description="${billingAccountId}"
target="EditBillingAccount?billingAccountId=${billingAccountId}"/>
        </field>
this would got thru the contorller that would call
setPortalPortletAttributes then return to a view request.


Bruno Busco sent the following on 11/2/2008 2:05 AM:

> Hi devs,
> I need your help.
>
> I am trying to complete the Portal/Portlet stuff adding the possibility to
> set some attributes specific to a Portlet instance.
>
> The idea is that when a portlet is defined, a form is defined also and
> linked in the PortalPortlet entity with something similar to this:
>     <PortalPortlet portalPortletId="LOGIN" portletName="Login"
> description="Login form"
>                    screenName="loginPortlet"
> screenLocation="component://common/widget/PortletScreens.xml"
>                    editFormName="LoginPortletEdit"
> editFormLocation="component://common/widget/PortletEditForms.xml" />
>
> The form is needed to edit a particular Portlet instance attributes. This
> extends from a common frame defined in the framework like this:
>     <form name="CommonPortletEdit" type="single"
> target="setPortalPortletAttributes" title=""
> default-map-name="PortalPortletAttributeMap">
>         <field name="portalPageId"><hidden/></field>
>         <field name="portalPortletId"><hidden/></field>
>         <field name="portletSeqId"><hidden/></field>
>         <field name="submitButton" title="${uiLabelMap.CommonEdit}"><submit
> button-type="button"/></field>
>     </form>
>
> Using this method an example of a specific portlet attribute editing form
> could be:
>     <form name="LoginPortletEdit" extends="CommonPortletEdit"
> extends-resource="component://common/widget/CommonForms.xml">
>         <field name="ItemsToShow">
>             <drop-down allow-empty="false">
>                 <option key="5"/>
>                 <option key="15"/>
>                 <option key="20"/>
>                 <option key="25"/>
>                 <option key="30"/>
>                 <option key="35"/>
>             </drop-down>
>         </field>
>     </form>
>
> In this example I supposed that the portlet has an attribute "ItemsToShow"
> that tells the portlet how many items to show.
>
> When the user submits one of the portlet attributes editing forms, the
> setPortalPortletAttributes service is triggered.
>
> My problem is now how to make this service able to retrieve from the
> submitted form the list of fields so that the Attribute entities can be
> created/updated.
>
> Is there an example of this in OFBiz?
> How can the service receive a map of fields that is not constant to iterate
> on?
>
> Many thanks for your help!
> -Bruno
>
Reply | Threaded
Open this post in threaded view
|

Re: How to receive in a service a variable list of fields from a form (and iterate on it)?

Bruno Busco
Hi BJ,
thank you for your help.
I apologize not sure to have well understood.

In the example you give, all fields are taken from the form's
default-entity.

I am looking for a way to put fields in a form widget that are not defined
as fields of an entity and neither as parameters of a serivice.
The service the form widget targets to should receive the fields in a map
and being able to iterate through these.

-Bruno

2008/11/2 BJ Freeman <[hidden email]>

> in ofbiz forms are fixed, like most you see in widgets and ftls.
> you have a entity and/or context that stores the info, like in maps.
> you then use the widget/ftl form to display the data in the entity or
> context.
> the ItemsToShow would be a map.
> you would then iterate the map. you can see many examples of this.
> you then set a field on the selection
> here is an example you can find it in the blllingaccountsform.xml
>    <form name="ListBillingAccounts" type="list"
> list-name="billingAccounts" paginate-target="FindBillingAccount"
> default-entity-name="BillingAccount"
>        odd-row-style="alternate-row" default-table-style="basic-table
> hover-bar">
>        <field name="billingAccountId" widget-style="buttontext">
>            <hyperlink description="${billingAccountId}"
> target="EditBillingAccount?billingAccountId=${billingAccountId}"/>
>        </field>
> this would got thru the contorller that would call
> setPortalPortletAttributes then return to a view request.
>
>
> Bruno Busco sent the following on 11/2/2008 2:05 AM:
> > Hi devs,
> > I need your help.
> >
> > I am trying to complete the Portal/Portlet stuff adding the possibility
> to
> > set some attributes specific to a Portlet instance.
> >
> > The idea is that when a portlet is defined, a form is defined also and
> > linked in the PortalPortlet entity with something similar to this:
> >     <PortalPortlet portalPortletId="LOGIN" portletName="Login"
> > description="Login form"
> >                    screenName="loginPortlet"
> > screenLocation="component://common/widget/PortletScreens.xml"
> >                    editFormName="LoginPortletEdit"
> > editFormLocation="component://common/widget/PortletEditForms.xml" />
> >
> > The form is needed to edit a particular Portlet instance attributes. This
> > extends from a common frame defined in the framework like this:
> >     <form name="CommonPortletEdit" type="single"
> > target="setPortalPortletAttributes" title=""
> > default-map-name="PortalPortletAttributeMap">
> >         <field name="portalPageId"><hidden/></field>
> >         <field name="portalPortletId"><hidden/></field>
> >         <field name="portletSeqId"><hidden/></field>
> >         <field name="submitButton"
> title="${uiLabelMap.CommonEdit}"><submit
> > button-type="button"/></field>
> >     </form>
> >
> > Using this method an example of a specific portlet attribute editing form
> > could be:
> >     <form name="LoginPortletEdit" extends="CommonPortletEdit"
> > extends-resource="component://common/widget/CommonForms.xml">
> >         <field name="ItemsToShow">
> >             <drop-down allow-empty="false">
> >                 <option key="5"/>
> >                 <option key="15"/>
> >                 <option key="20"/>
> >                 <option key="25"/>
> >                 <option key="30"/>
> >                 <option key="35"/>
> >             </drop-down>
> >         </field>
> >     </form>
> >
> > In this example I supposed that the portlet has an attribute
> "ItemsToShow"
> > that tells the portlet how many items to show.
> >
> > When the user submits one of the portlet attributes editing forms, the
> > setPortalPortletAttributes service is triggered.
> >
> > My problem is now how to make this service able to retrieve from the
> > submitted form the list of fields so that the Attribute entities can be
> > created/updated.
> >
> > Is there an example of this in OFBiz?
> > How can the service receive a map of fields that is not constant to
> iterate
> > on?
> >
> > Many thanks for your help!
> > -Bruno
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: How to receive in a service a variable list of fields from a form (and iterate on it)?

BJ Freeman
apologize was focusing on the flow and how to list.
 once a wake up I can give you a better one for you.
services are generally passed maps, in the context.


Bruno Busco sent the following on 11/2/2008 7:50 AM:

> Hi BJ,
> thank you for your help.
> I apologize not sure to have well understood.
>
> In the example you give, all fields are taken from the form's
> default-entity.
>
> I am looking for a way to put fields in a form widget that are not defined
> as fields of an entity and neither as parameters of a serivice.
> The service the form widget targets to should receive the fields in a map
> and being able to iterate through these.
>
> -Bruno
>
> 2008/11/2 BJ Freeman <[hidden email]>
>
>> in ofbiz forms are fixed, like most you see in widgets and ftls.
>> you have a entity and/or context that stores the info, like in maps.
>> you then use the widget/ftl form to display the data in the entity or
>> context.
>> the ItemsToShow would be a map.
>> you would then iterate the map. you can see many examples of this.
>> you then set a field on the selection
>> here is an example you can find it in the blllingaccountsform.xml
>>    <form name="ListBillingAccounts" type="list"
>> list-name="billingAccounts" paginate-target="FindBillingAccount"
>> default-entity-name="BillingAccount"
>>        odd-row-style="alternate-row" default-table-style="basic-table
>> hover-bar">
>>        <field name="billingAccountId" widget-style="buttontext">
>>            <hyperlink description="${billingAccountId}"
>> target="EditBillingAccount?billingAccountId=${billingAccountId}"/>
>>        </field>
>> this would got thru the contorller that would call
>> setPortalPortletAttributes then return to a view request.
>>
>>
>> Bruno Busco sent the following on 11/2/2008 2:05 AM:
>>> Hi devs,
>>> I need your help.
>>>
>>> I am trying to complete the Portal/Portlet stuff adding the possibility
>> to
>>> set some attributes specific to a Portlet instance.
>>>
>>> The idea is that when a portlet is defined, a form is defined also and
>>> linked in the PortalPortlet entity with something similar to this:
>>>     <PortalPortlet portalPortletId="LOGIN" portletName="Login"
>>> description="Login form"
>>>                    screenName="loginPortlet"
>>> screenLocation="component://common/widget/PortletScreens.xml"
>>>                    editFormName="LoginPortletEdit"
>>> editFormLocation="component://common/widget/PortletEditForms.xml" />
>>>
>>> The form is needed to edit a particular Portlet instance attributes. This
>>> extends from a common frame defined in the framework like this:
>>>     <form name="CommonPortletEdit" type="single"
>>> target="setPortalPortletAttributes" title=""
>>> default-map-name="PortalPortletAttributeMap">
>>>         <field name="portalPageId"><hidden/></field>
>>>         <field name="portalPortletId"><hidden/></field>
>>>         <field name="portletSeqId"><hidden/></field>
>>>         <field name="submitButton"
>> title="${uiLabelMap.CommonEdit}"><submit
>>> button-type="button"/></field>
>>>     </form>
>>>
>>> Using this method an example of a specific portlet attribute editing form
>>> could be:
>>>     <form name="LoginPortletEdit" extends="CommonPortletEdit"
>>> extends-resource="component://common/widget/CommonForms.xml">
>>>         <field name="ItemsToShow">
>>>             <drop-down allow-empty="false">
>>>                 <option key="5"/>
>>>                 <option key="15"/>
>>>                 <option key="20"/>
>>>                 <option key="25"/>
>>>                 <option key="30"/>
>>>                 <option key="35"/>
>>>             </drop-down>
>>>         </field>
>>>     </form>
>>>
>>> In this example I supposed that the portlet has an attribute
>> "ItemsToShow"
>>> that tells the portlet how many items to show.
>>>
>>> When the user submits one of the portlet attributes editing forms, the
>>> setPortalPortletAttributes service is triggered.
>>>
>>> My problem is now how to make this service able to retrieve from the
>>> submitted form the list of fields so that the Attribute entities can be
>>> created/updated.
>>>
>>> Is there an example of this in OFBiz?
>>> How can the service receive a map of fields that is not constant to
>> iterate
>>> on?
>>>
>>> Many thanks for your help!
>>> -Bruno
>>>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to receive in a service a variable list of fields from a form (and iterate on it)?

Bruno Busco
Thank you, BJ  ;-)
May be this is a very basic thing but it is blocking me.

- Bruno

2008/11/2 BJ Freeman <[hidden email]>

> apologize was focusing on the flow and how to list.
>  once a wake up I can give you a better one for you.
> services are generally passed maps, in the context.
>
>
> Bruno Busco sent the following on 11/2/2008 7:50 AM:
> > Hi BJ,
> > thank you for your help.
> > I apologize not sure to have well understood.
> >
> > In the example you give, all fields are taken from the form's
> > default-entity.
> >
> > I am looking for a way to put fields in a form widget that are not
> defined
> > as fields of an entity and neither as parameters of a serivice.
> > The service the form widget targets to should receive the fields in a map
> > and being able to iterate through these.
> >
> > -Bruno
> >
> > 2008/11/2 BJ Freeman <[hidden email]>
> >
> >> in ofbiz forms are fixed, like most you see in widgets and ftls.
> >> you have a entity and/or context that stores the info, like in maps.
> >> you then use the widget/ftl form to display the data in the entity or
> >> context.
> >> the ItemsToShow would be a map.
> >> you would then iterate the map. you can see many examples of this.
> >> you then set a field on the selection
> >> here is an example you can find it in the blllingaccountsform.xml
> >>    <form name="ListBillingAccounts" type="list"
> >> list-name="billingAccounts" paginate-target="FindBillingAccount"
> >> default-entity-name="BillingAccount"
> >>        odd-row-style="alternate-row" default-table-style="basic-table
> >> hover-bar">
> >>        <field name="billingAccountId" widget-style="buttontext">
> >>            <hyperlink description="${billingAccountId}"
> >> target="EditBillingAccount?billingAccountId=${billingAccountId}"/>
> >>        </field>
> >> this would got thru the contorller that would call
> >> setPortalPortletAttributes then return to a view request.
> >>
> >>
> >> Bruno Busco sent the following on 11/2/2008 2:05 AM:
> >>> Hi devs,
> >>> I need your help.
> >>>
> >>> I am trying to complete the Portal/Portlet stuff adding the possibility
> >> to
> >>> set some attributes specific to a Portlet instance.
> >>>
> >>> The idea is that when a portlet is defined, a form is defined also and
> >>> linked in the PortalPortlet entity with something similar to this:
> >>>     <PortalPortlet portalPortletId="LOGIN" portletName="Login"
> >>> description="Login form"
> >>>                    screenName="loginPortlet"
> >>> screenLocation="component://common/widget/PortletScreens.xml"
> >>>                    editFormName="LoginPortletEdit"
> >>> editFormLocation="component://common/widget/PortletEditForms.xml" />
> >>>
> >>> The form is needed to edit a particular Portlet instance attributes.
> This
> >>> extends from a common frame defined in the framework like this:
> >>>     <form name="CommonPortletEdit" type="single"
> >>> target="setPortalPortletAttributes" title=""
> >>> default-map-name="PortalPortletAttributeMap">
> >>>         <field name="portalPageId"><hidden/></field>
> >>>         <field name="portalPortletId"><hidden/></field>
> >>>         <field name="portletSeqId"><hidden/></field>
> >>>         <field name="submitButton"
> >> title="${uiLabelMap.CommonEdit}"><submit
> >>> button-type="button"/></field>
> >>>     </form>
> >>>
> >>> Using this method an example of a specific portlet attribute editing
> form
> >>> could be:
> >>>     <form name="LoginPortletEdit" extends="CommonPortletEdit"
> >>> extends-resource="component://common/widget/CommonForms.xml">
> >>>         <field name="ItemsToShow">
> >>>             <drop-down allow-empty="false">
> >>>                 <option key="5"/>
> >>>                 <option key="15"/>
> >>>                 <option key="20"/>
> >>>                 <option key="25"/>
> >>>                 <option key="30"/>
> >>>                 <option key="35"/>
> >>>             </drop-down>
> >>>         </field>
> >>>     </form>
> >>>
> >>> In this example I supposed that the portlet has an attribute
> >> "ItemsToShow"
> >>> that tells the portlet how many items to show.
> >>>
> >>> When the user submits one of the portlet attributes editing forms, the
> >>> setPortalPortletAttributes service is triggered.
> >>>
> >>> My problem is now how to make this service able to retrieve from the
> >>> submitted form the list of fields so that the Attribute entities can be
> >>> created/updated.
> >>>
> >>> Is there an example of this in OFBiz?
> >>> How can the service receive a map of fields that is not constant to
> >> iterate
> >>> on?
> >>>
> >>> Many thanks for your help!
> >>> -Bruno
> >>>
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: How to receive in a service a variable list of fields from a form (and iterate on it)?

David E Jones
In reply to this post by Bruno Busco

On Nov 2, 2008, at 9:50 AM, Bruno Busco wrote:

> I am looking for a way to put fields in a form widget that are not  
> defined
> as fields of an entity and neither as parameters of a serivice.
> The service the form widget targets to should receive the fields in  
> a map
> and being able to iterate through these.

To do this you would have to write a custom event using Java or simple-
method or a scripting language, have it build the Map to pass to the  
service, and then call the service.

The main constraint is that HTTP only takes a flat map of parameters  
(name/value pairs, all Strings). The ServiceEventHandler will map  
types, but there is no way to tell it to put certain field into a Map  
that would be passed to the service as a field (if that's what you're  
looking for). They all go into a Map, but that Map is the context of  
the service itself, or all fields in that Map will be put into the  
context at the very least.

-David


Reply | Threaded
Open this post in threaded view
|

Re: How to receive in a service a variable list of fields from a form (and iterate on it)?

Bruno Busco
Many thanks David,
I will try to go through the event making map solution.

-Bruno

2008/11/2 David E Jones <[hidden email]>

>
> On Nov 2, 2008, at 9:50 AM, Bruno Busco wrote:
>
>  I am looking for a way to put fields in a form widget that are not defined
>> as fields of an entity and neither as parameters of a serivice.
>> The service the form widget targets to should receive the fields in a map
>> and being able to iterate through these.
>>
>
> To do this you would have to write a custom event using Java or
> simple-method or a scripting language, have it build the Map to pass to the
> service, and then call the service.
>
> The main constraint is that HTTP only takes a flat map of parameters
> (name/value pairs, all Strings). The ServiceEventHandler will map types, but
> there is no way to tell it to put certain field into a Map that would be
> passed to the service as a field (if that's what you're looking for). They
> all go into a Map, but that Map is the context of the service itself, or all
> fields in that Map will be put into the context at the very least.
>
> -David
>
>
>