PDA

View Full Version : How to reload the screen on custom action to reflect new added fields



Ary_Fortune
25 Sep 2013, 3:33 AM
Hello All,

I have a screen and on some custom action, Few fields (Depending on the data in database) get generated. and the json string passed to the page gets updated.

But after the custom action this updated json string does not populate the newly added fields on the page.
The page does not re-render. I also have data entered on the page. While I do so I need the data to be intact.

The custom tags in the jsp are updating the json data.

Please help.

existdissolve
25 Sep 2013, 3:55 AM
Hello All,

I have a screen and on some custom action, Few fields (Depending on the data in database) get generated. and the json string passed to the page gets updated.

But after the custom action this updated json string does not populate the newly added fields on the page.
The page does not re-render. I also have data entered on the page. While I do so I need the data to be intact.

The custom tags in the jsp are updating the json data.

Please help.

Can you show some code?

How is the "json string passed to the page" delivered? I'm assuming via an AJAX request, but you need to be specific. If via an AJAX request, it seems like you simply need to add some code in the success handler to regenerate the fields based on the json data that you update.

Ary_Fortune
25 Sep 2013, 4:02 AM
We have our framework javascript files which process the fields and layouts.
So I had earlier thought that adding new fields to the json , the framework will handle it.

There are already few fields on the page, I am just adding new fields to the json.
The existing fields reflect properly, so do I need to do anything else to the response to populate these.

existdissolve
25 Sep 2013, 4:11 AM
We have our framework javascript files which process the fields and layouts.
So I had earlier thought that adding new fields to the json , the framework will handle it.

There are already few fields on the page, I am just adding new fields to the json.
The existing fields reflect properly, so do I need to do anything else to the response to populate these.

It more than likely will handle it, but depending on the type of component/view you're using to display these fields, you will probably have to do something to trigger the update of the view.

As before, can you show a snippet of code? Without that, or at least some more explanation of what kinds of fields and layouts you're dealing with (what do you mean by "layout", for example), it's difficult to tell you what you need to do.

Ary_Fortune
25 Sep 2013, 4:55 AM
Actually I have done anything in the JavaScript, just the JSon string that was getting passed to the framework js is changed to have new fields in it
For e.g.
Below is the json string

{
"classPath": "bsxref_hdr",
"layout":{ "abclistfield1" : {"container":"cont_7", "contType":1 },
"updatedby" : {"container":"cont_10", "index":16, "contType":1}},
"labels": {"updatedby": { label: "Updated By" }, "abclistfield1":{ label : "TextField" }},


"pageData": {
"values": {
"updatedby": null,
"abclistfield1": null
},
"attributes": {
"updatedby": "protected",
"abclistfield1": "optional"
},


focus: {"firstEnterableField": "updatedby"},


"messages": null
}

Here if updatedby was already present on the page then on custom action when the response is sent, then the respsonse json string is modified to have abclistfield1 field in it too.

Here abclistfield1 comes from data base and its data type can be any. But the page does not render the fields again here. It is difficult for me to post the entire javaSript code here.
But Just want to know the will just adding fields to the json string populate them or Do we need to do something in the view handler or controller javaSript to reload the page or something Like it.

I am kind of new to ExtJs.

existdissolve
25 Sep 2013, 10:10 AM
Without knowing what your app actually does with that JSON string, it's difficult to say what you need to do. If that string is being used a configuration for how to build out particular components, then you will probably have to run the new string through whatever process is used when the page loads and generates the components.

But again, without knowing how this is being used, it's tough to say more than that.

Ary_Fortune
7 Oct 2013, 3:47 AM
Thanks All,

I found out that the response that I got from the custom tag java code has to be formulated into the javaScript fields and these constructed fields have to be added to the container as below.

vCFContainer.add(new Ext.form.Field(config));

The config has the field information from the json response and it displays the fields.