Custom XForm code to populate Repeated Grid

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

Custom XForm code to populate Repeated Grid

kushp
Hi Alex,

Thanks for your information regarding the custom property used to specify the custom resources. 

For now, I'm trying to put my code in the form definition. Once it works, I'll create a new separate file for it.

However, I'm facing a problem to access the second element of the repeated grid. I'm able to populate the first element of the repeated grid easily. Here's the code to do so:

<xf:action class="fr-set-control-value-action">
                        <xf:var name="control-name" value="'control-3'"/>
                        <xf:var name="control-value" value="/json/proposal/_[.]/lastname"/>
                    </xf:action>

The control-3 is inside the repeated grid. I have got the following questions:

How to access the repeated grid instance? When I have two identical rows in the repeated grid, the Main Instance of the form contains two entries of the repeated grid. However, I don't see any identifier to distinguish both grid.

Is there any method to get the count of the number of elements in JSON Array that is returned by the HTTP service.

- Kush

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Custom XForm code to populate Repeated Grid

Alessandro  Vernet
Administrator
Hi Kush,

The `<xf:action class="fr-set-control-value-action">` and ` <xf:var>` are
just encoding what you enter in the in the Actions dialog. I recommend you
set your action to store what the service returns in a dataset, then write
XForms code that uses that dataset to populate the repeated grid based on
what you have in the dataset. For now, you can have the code run upon some
button you add to the form being pressed. Later you'll want to have it run
right away right after the action runs.

You'll let me know if this helps.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Custom XForm code to populate Repeated Grid

kushp
Hi Alex,

I'm progressing on this task. I've saved the response of the Action to a dataset. Currently, I'm trying to populate the grid on a button click (a trigger, in terms of XForms ;)) as you've mentioned in the previous reply. I've also understood how the actual form definition is constructed based on UI actions and is utilized to produce the Orbeon web form. 

As per my understanding, the final result is to simply add the elements of grid-x-iteration(with values) to the main instance of fr-form-instance after the button is clicked. In the <xh:body> the form will be superbly created from the main instance. It's beautiful to see that other than the main instance rest of the code is never updated. The data would be stored in a dataset and can be retrieved using the fr:dataset() function. <xf:insert> and <xf:repeat> are the helping friends to achieve this. I've gone through the syntax of both of them and tried to add an element to the main instance. 

I'm confronting with the following:

Where to place the <xf:insert> in order to add the grid-x-iteration elements? I tried it placing in the <xf:trigger> element itself in the <xh:body>
What is the value of the context attribute of the <xf:insert> element? I see that the rest of the controls are referenced using the bind attribute.
How to specify the values from the dataset to the grid controls? Right now I'm just using the empty instance of the grid-2-template.

This resource was used to understand the insert and repeat elements. 

Kush

On Sunday, May 20, 2018 at 4:27:25 AM UTC+5:30, Alessandro Vernet wrote:
Hi Kush,

The `<xf:action class="fr-set-control-value-action">` and ` <xf:var>` are
just encoding what you enter in the in the Actions dialog. I recommend you
set your action to store what the service returns in a dataset, then write
XForms code that uses that dataset to populate the repeated grid based on
what you have in the dataset. For now, you can have the code run upon some
button you add to the form being pressed. Later you'll want to have it run
right away right after the action runs.

You'll let me know if this helps.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: <a href="http://discuss.orbeon.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;">http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Custom XForm code to populate Repeated Grid

kushp
I've attached the source file of the form with my custom code and put a few comments.

On Friday, May 25, 2018 at 5:12:05 PM UTC+5:30, [hidden email] wrote:
Hi Alex,

I'm progressing on this task. I've saved the response of the Action to a dataset. Currently, I'm trying to populate the grid on a button click (a trigger, in terms of XForms ;)) as you've mentioned in the previous reply. I've also understood how the actual form definition is constructed based on UI actions and is utilized to produce the Orbeon web form. 

As per my understanding, the final result is to simply add the elements of grid-x-iteration(with values) to the main instance of fr-form-instance after the button is clicked. In the <xh:body> the form will be superbly created from the main instance. It's beautiful to see that other than the main instance rest of the code is never updated. The data would be stored in a dataset and can be retrieved using the fr:dataset() function. <xf:insert> and <xf:repeat> are the helping friends to achieve this. I've gone through the syntax of both of them and tried to add an element to the main instance. 

I'm confronting with the following:

Where to place the <xf:insert> in order to add the grid-x-iteration elements? I tried it placing in the <xf:trigger> element itself in the <xh:body>
What is the value of the context attribute of the <xf:insert> element? I see that the rest of the controls are referenced using the bind attribute.
How to specify the values from the dataset to the grid controls? Right now I'm just using the empty instance of the grid-2-template.

This <a href="http://wiki.orbeon.com/forms/how-to/logic/repeat-insert-position" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwiki.orbeon.com%2Fforms%2Fhow-to%2Flogic%2Frepeat-insert-position\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHeInkorAZMSVZLBwjSrOgTy6TjDQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwiki.orbeon.com%2Fforms%2Fhow-to%2Flogic%2Frepeat-insert-position\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHeInkorAZMSVZLBwjSrOgTy6TjDQ&#39;;return true;">resource was used to understand the insert and repeat elements. 

Kush

On Sunday, May 20, 2018 at 4:27:25 AM UTC+5:30, Alessandro Vernet wrote:
Hi Kush,

The `<xf:action class="fr-set-control-value-action">` and ` <xf:var>` are
just encoding what you enter in the in the Actions dialog. I recommend you
set your action to store what the service returns in a dataset, then write
XForms code that uses that dataset to populate the repeated grid based on
what you have in the dataset. For now, you can have the code run upon some
button you add to the form being pressed. Later you'll want to have it run
right away right after the action runs.

You'll let me know if this helps.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: <a href="http://discuss.orbeon.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;">http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

grid_custom.xml (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Custom XForm code to populate Repeated Grid

kushp
This is sample data returned to Orbeon:

{
    "proposal": {
        "here": "there",
        "there": "here",
        "nameGrid": [
            {
                "firstname": "lonely",
                "lastname": "ether"
            },
            {
                "firstname": "smart",
                "lastname": "wombat"
            },
            {
                "firstname": "shinny",
                "lastname": "metal"
            },
            {
                "firstname": "noisy",
                "lastname": "star"
            }
        ]
    }
}



On Friday, May 25, 2018 at 5:18:13 PM UTC+5:30, [hidden email] wrote:
I've attached the source file of the form with my custom code and put a few comments.

On Friday, May 25, 2018 at 5:12:05 PM UTC+5:30, [hidden email] wrote:
Hi Alex,

I'm progressing on this task. I've saved the response of the Action to a dataset. Currently, I'm trying to populate the grid on a button click (a trigger, in terms of XForms ;)) as you've mentioned in the previous reply. I've also understood how the actual form definition is constructed based on UI actions and is utilized to produce the Orbeon web form. 

As per my understanding, the final result is to simply add the elements of grid-x-iteration(with values) to the main instance of fr-form-instance after the button is clicked. In the <xh:body> the form will be superbly created from the main instance. It's beautiful to see that other than the main instance rest of the code is never updated. The data would be stored in a dataset and can be retrieved using the fr:dataset() function. <xf:insert> and <xf:repeat> are the helping friends to achieve this. I've gone through the syntax of both of them and tried to add an element to the main instance. 

I'm confronting with the following:

Where to place the <xf:insert> in order to add the grid-x-iteration elements? I tried it placing in the <xf:trigger> element itself in the <xh:body>
What is the value of the context attribute of the <xf:insert> element? I see that the rest of the controls are referenced using the bind attribute.
How to specify the values from the dataset to the grid controls? Right now I'm just using the empty instance of the grid-2-template.

This <a href="http://wiki.orbeon.com/forms/how-to/logic/repeat-insert-position" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwiki.orbeon.com%2Fforms%2Fhow-to%2Flogic%2Frepeat-insert-position\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHeInkorAZMSVZLBwjSrOgTy6TjDQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwiki.orbeon.com%2Fforms%2Fhow-to%2Flogic%2Frepeat-insert-position\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHeInkorAZMSVZLBwjSrOgTy6TjDQ&#39;;return true;">resource was used to understand the insert and repeat elements. 

Kush

On Sunday, May 20, 2018 at 4:27:25 AM UTC+5:30, Alessandro Vernet wrote:
Hi Kush,

The `<xf:action class="fr-set-control-value-action">` and ` <xf:var>` are
just encoding what you enter in the in the Actions dialog. I recommend you
set your action to store what the service returns in a dataset, then write
XForms code that uses that dataset to populate the repeated grid based on
what you have in the dataset. For now, you can have the code run upon some
button you add to the form being pressed. Later you'll want to have it run
right away right after the action runs.

You'll let me know if this helps.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: <a href="http://discuss.orbeon.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;">http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Custom XForm code to populate Repeated Grid

kushp
In reply to this post by Alessandro Vernet
Hi Alex,

Can you please reply to my questions?

Thanks,
Kush

On Sunday, May 20, 2018 at 4:27:25 AM UTC+5:30, Alessandro Vernet wrote:
Hi Kush,

The `<xf:action class="fr-set-control-value-action">` and ` <xf:var>` are
just encoding what you enter in the in the Actions dialog. I recommend you
set your action to store what the service returns in a dataset, then write
XForms code that uses that dataset to populate the repeated grid based on
what you have in the dataset. For now, you can have the code run upon some
button you add to the form being pressed. Later you'll want to have it run
right away right after the action runs.

You'll let me know if this helps.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: <a href="http://discuss.orbeon.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdiscuss.orbeon.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF5V5zfD-87RVoalaG4cqO_RzdDcA&#39;;return true;">http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Custom XForm code to populate Repeated Grid

Alessandro  Vernet
Administrator
Just a quick note for those who would find this thread: since this was
getting quite specific, we've taken it offline with Kush.

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet