How to save webblocks from the main page?

How to save webblocks from the main page?

  
Hi,

In my application, I have a feature that is build custom reports.

So, I've built different webblock that are possible parts of the template. I'm able to define a template choosing which webblocks will constitute it.

To fulfill, I've put them on a table records and the chosen webblocks are displayed.

What I want to know and I don't know how is: how do I have, at the end, a button save that saves the data inside each webblock that is displayed? Is it possible?

Tks,
Hi Carlos,

Why dont you use temporary tables?
Example: When you choose one webblock you save the data in one temporary table, and when you click the Save button at the end, copy all the data which you have in the temporary table to the table where you want to save it.
I dont know if its what you want but i hope i could help you.

Best Regards,
Diogo Miguel
Hi Carlos,

Another way is to have in the WebBlock a hidden Button and you can notify it's identifier to main page, where you should store it.
Then, at the end when you want to save the inner information you can have a button in that main page to save your information and use a Widget Click or jQuery command to click the hidden button, passing the button identifier you just stored before (notified by the WebBlock).
This case you avoid extra entities, SQL operations..all is processed in client-side.
Hope it helps.

Kind Regards,
Gonçalo Martins
First of all, thank you Diogo and Gonçalo.

I prefer your solution Gonçalo but there is one thing that I don't know how to do:

"Another way is to have in the WebBlock a hidden Button and you can notify it's identifier to main page, where you should store it."

I think I know the actions that you're refering to but I don't know how to obtain this behaviour. Can you give me a quick example please?

This would solve my problem!! :)
You can also use one in each webblock notify.
In webscrem (parent)'ll do getnotifymessage webblock for each variable.
 
After you use the variables that hold the data of webblocks.
 
This way can you make the recording.


Hope it helps

Best Regards,
Luís Teixeira
Thank Luis but there is something that I don't know how it works:

1 - The webblocks are dynamic and are inside a table records

2 - I know how to send messages when you are in a popup and want to do something on the "parent" page but here, I can not see how that I click in the "main button" and will call each hidden save button inside the webblock.
This solution will be of great help to an application I am currently supporting as well, but only if I am able to remotely invoke the hidden button on each of the web blocks displayed on the main page. As with Carlos, the web blocks I am using are also displayed dynamically, and there may be from 1 - <n> of them, depending on the circumstances. 
I have been able to notify the "parent" page from the preparation action of each web-block and sucessfully pass the unique id of the hidden button back to the parent, to be stored in a list. 
However, I also need the ability to iterate through that list and "click" the button associated with each id.  So far, I have been unable to achieve that.
Chuck Doherty


Chuck Doherty wrote:
This solution will be of great help to an application I am currently supporting as well, but only if I am able to remotely invoke the hidden button on each of the web blocks displayed on the main page. As with Carlos, the web blocks I am using are also displayed dynamically, and there may be from 1 - <n> of them, depending on the circumstances. 
I have been able to notify the "parent" page from the preparation action of each web-block and sucessfully pass the unique id of the hidden button back to the parent, to be stored in a list. 
However, I also need the ability to iterate through that list and "click" the button associated with each id.  So far, I have been unable to achieve that.
Chuck Doherty

 
 
Chuck,

How can you do it? Can you give me an explanation of the flow?

TKs,
 
Carlos,

All that I am able to accomplish so far is to pass the ID of the button in the web block to its parent; I am still unable to use the Widget Click action to activate that buttom from the parent page when I am done,   

The first part is easy; I put a Notify Widget in the preparation section of the web block, and for the message I pass the id of the "hidden" button.  You need to give the button an explicit name in order to be able to do that. 

Inside the OnNotify action of the parent page, I read the message to get the id of the button, and append that as a new entry into a local variable of type Record List  list of "text" records. 

Then later on, I can iterate through that list to get the id's of all the hidden buttons in the web blocks, but I am at a dead end at that point since I cannot "click" them remotely.  Once I can figure out how to do that (if it is even possible) the birds will sing in the trees.

Chuck
Hi all,

I think that it could be simplier if you describe your requirements and attach an eSpace with what you have, because this questions are a little bit ambiguous and according to the needs you can have some different approaches.

Kind Regards,
Gonçalo Martins
Chuck Doherty wrote:
Carlos,

All that I am able to accomplish so far is to pass the ID of the button in the web block to its parent; I am still unable to use the Widget Click action to activate that buttom from the parent page when I am done,   

The first part is easy; I put a Notify Widget in the preparation section of the web block, and for the message I pass the id of the "hidden" button.  You need to give the button an explicit name in order to be able to do that. 

Inside the OnNotify action of the parent page, I read the message to get the id of the button, and append that as a new entry into a local variable of type Record List  list of "text" records. 

Then later on, I can iterate through that list to get the id's of all the hidden buttons in the web blocks, but I am at a dead end at that point since I cannot "click" them remotely.  Once I can figure out how to do that (if it is even possible) the birds will sing in the trees.

Chuck
 
 Chuck -

Have you tried the "Widget_Click" Action (from Rich Widgets) once the parent page has the IDs?

J.Ja
Justin,

Yes, I have done that, but it does not seem able to "see" them from the parent.  I will venture back into the code again shortly so see if I am missing something obvious.

Chuck



Hi all,
 
Based on the post from Luís, I just build a very simple sample where you can check how it can be built. 
Nonetheless, let me already highlight some possible problems with this solution:
  • Several ajax request will be created, one for each webBlock;
  • You will have several database transactions, also one for each webBlock;
  • You don't control when all the requests ended, it will be necessary to create more logic using notifies.

Regards,
Paulo Garrudo
Chuck -

If you have any Ajax Refreshes within that Web Block that occur after the ID is passed to the parent, and cause that button to refresh, it is quite likely that the button gets a new ID. My best suggestion is to use the F12 tools in IE or Chrome or Firebug and look for JavaScript errors, or trace the JS if needed. That may give you the clue you need.

J.Ja
Here is what I am finding, and it is very interesting;  When the button (the one in the web block) is clicked manually, it invokes the associated action just fine, but not when called via the widget-click action.  I also verified that the id's of the buttons are also consistent after the page is rendered.    But here is the real puzzler: if I attach a confirmation dialog to the button, the confirmation popup DOES appear both when the button is clicked manually or via the widget.  BUT the action associated with it is not invoked. 
cd
Let me add that I mean that the associated action is not invoked only when "clicked" remotely, even though the confirmation dialog does appear.  The actions and the confirmation are both processed by clicking manually.
Chuck Doherty wrote:
Let me add that I mean that the associated action is not invoked only when "clicked" remotely, even though the confirmation dialog does appear.  The actions and the confirmation are both processed by clicking manually.
 
 Hello Guys,

I've followed a different aproach then Garrudo. 

Find in the attach an espace that as two web blocks, each with a different save button and a third web block, that takes in the ID of a button. That third webblock attaches an onclick javascript event to the element that has the received id.

When that click occurs, there's a javascript function that will look at all the buttons with "multisave-<order>" class and will call click on each button, following the "<order>" that is defined in each of the buttons. 

It is needed that the third web block is added after the button that the event will be attached to. It is also needed that each of the buttons that is gling to be clicked has the class multisave-0 for example. See the example...
Chuck -

That sounds very much so like a bug in the system!

J.Ja
Chuck Doherty wrote:
Let me add that I mean that the associated action is not invoked only when "clicked" remotely, even though the confirmation dialog does appear.  The actions and the confirmation are both processed by clicking manually.
 
 Hi Chuck.

Can you post your eSpace so that we can debug it?

I don't really understand whta the problem seems to be.

Also, have you seen the eSpace that I've posted? I believe that you can use it to implement a solution to your case.

Cheers,
Pedro
Hi,

I have to agree with Pedro.
The eSpace seems to be a good support to implement your solutions and without your specific eSpace we can't help you more than this.

Kind Regards,
Gonçalo Martins
Tks everyone! :)

I'm using perfectly the solution that Pedro suggested. 
Hello everybody I take here to put a solution that I have used successfully and quite simply, I don't like and I don't agree with the use of temporary tables, I think this solution is not good to use the system consistently, the system message exchange is quite limited too,  only a simple text message can be chantged between page and webblock, I found was to create structures for everything I need within a webblock and always transform this structure into an XML and return to the other side record, was very simple to exchange the information thus beyond fully structured. How to notify only supports text xml then step one is complete where the entire structure is overkill to spend just one more message is perfect for passing data forms or parts of it. I'll set up a small example and post here soon.
The espace involved with this is prohibitively large as well as dependent on many others, making it impractical to post here.  I will see about creating a smaller version to show the exact issues.
I am facing exactly the same problem as Chuck Doherty.
the process works fine, until the Widget_Click action is called. This action is not invoking the button-click in the webblock.

I´ve tested this in both Firefox and IE.
I´ve attached a sample solution where you can see my solution.

I´ll now start checking the other solutions posted in this forum.
I managed to get the test eSpace working myself.
The only thing that went wrong was that the button calling the Widget_Click had the method Submit instead of Ajax. This resulted in recreating the screen and then searching for the button with the ID, which the system could not find, because the screen was rebuild.

Also the save-buttons in the webblocks need to have the method set to Ajax, because otherwise the screen will be refreshed before all webblocks are saved and you will still be missing unsaved data.

Attached is the new and working version of the test eSpace.