Solution model exceptions

Discuss all feature requests you have for a new Servoy versions here. Make sure to be clear about what you want, provide an example and indicate how important the feature is for you

Solution model exceptions

Postby martinh » Wed Jul 15, 2009 1:15 pm

Could it be an idea, to throw exceptions if you want to change a form by the solutionmodel and the form has already been loaded.

I just found that I have lot of troubles because somewhere a form was unexpected loaded earlier than I thought and that caused a lot of troubles.
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Solution model exceptions

Postby jcompagner » Tue Aug 11, 2009 9:44 pm

this is already implemented for some time now, will be in 4.1.4
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Solution model exceptions

Postby martinh » Tue Sep 01, 2009 10:13 am

Under what case # I can see this fix in the release announcement?
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Solution model exceptions

Postby jcompagner » Tue Sep 01, 2009 10:26 am

that wasnt listed it was an internal thing.

But if you touch a solution model form instance and the ui instance of that form was already there and not destroyed you should get a error in the developer.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Solution model exceptions

Postby Robert Huber » Tue Sep 01, 2009 12:15 pm

I can confirm that this has changed with 4.1.4 and I get the error message seen attached. I had to correct it with the command history.removeForm(formName); before using var form = solutionModel.getForm(formName); and setting solution properties like for example

Code: Select all
var paneFooter = form.newLabel(null, btnPosX, btnPosY, 220, 18);
   
// Set properties for pane footer (gradient) graphic
paneFooter.name = 'paneFooter';
paneFooter.styleClass = 'Default';
paneFooter.borderType = 'EmptyBorder, 0, 0, 0, 0';
paneFooter.imageMedia = solutionModel.getMedia('paneFooterGradientBG.png');
paneFooter.mediaOptions = SM_MEDIAOPTION.ENLARGE;
paneFooter.anchors = SM_ANCHOR.WEST | SM_ANCHOR.SOUTH | SM_ANCHOR.EAST;
paneFooter.showClick = false;
paneFooter.showFocus = false;
...


I have assumed that the cmd solutionModel.removeForm(); would do it too, but that doesn't work. Johann, could you say why? It would be more logical me to use this cmd. What is it now used for?

Regards, Robert


jcompagner wrote:that wasnt listed it was an internal thing.

But if you touch a solution model form instance and the ui instance of that form was already there and not destroyed you should get a error in the developer.
Attachments
Picture 1.png
Picture 1.png (33.78 KiB) Viewed 5295 times
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: Solution model exceptions

Postby jcompagner » Tue Sep 01, 2009 2:20 pm

solutionModel.removeForm() really deletes the form from the blueprint so you cant reuse it then and have to create that form again.

But if you call solutionModel.removeForm() on a form that is visible it will return false. And then if you modify it after that you will get the error.
So my guess is that sm.removeForm() really couldnt remove it.

But history.removeForm() also shouldnt help then because sm.remove calls history.remove to remove the live form instance
and then sm.remove also does something extra and deletes the form from the solution blueprint.

But looking at your example you really have to call history.remove() then get the form from the solution model and alter properties
if you would call solutionModel.remove then the call to get the form from the solution model should return null.
(if solutionModel.removeForm would return true)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Solution model exceptions

Postby Robert Huber » Tue Sep 01, 2009 6:25 pm

Hi Johann

Two uncertainties remain: What do you mean exactly by visible and what is your blueprint technically?

Below is my code in more detail. The code is used to create the (body) footer with a button to get the reports menu and appears everytime a menu is selected. A menu can of course be selected many times. The relevant code looks (shortened) like this:

Code of the menu selection (a big case stmt). The menu 801 for example is in domain SCHULE > Fachpersonen (I added a screenshot as an aid to read the code)

Code: Select all
function handleMenuSelected()
{
   /*
   Title:      The form will be shown. Register at domains form.
   
   Author:      Birgit Rieder, Robert Huber
   Created:   19.07.2007
   Modified:   05.08.2008,   hu: Default form for find mode for each menu added, stored in form variable this.defaultForm.
            06.10.2008,   hu: Menu sequence changed to Kanti-Feedback.
   
   Arguments:   -
   Returns:   -
   Notes:      -
   */
   
   var menuId = forms.BasConfiguration.getConfiguration().selectedMenuId;
   
   // Save the divider location for the main form and the last menu id:
   var dividerLocation = elements.vSplit.dividerLocation;
   forms.BasConfiguration.getConfiguration().setMainDividerLocation(dividerLocation); // Saves location and previous selected menu id
   
   // Save the divider locations for all the forms showed.
   forms.BasConfiguration.saveDividerLocationForFormName(elements.tabSelection.getTabFormNameAt(1));
   forms.BasConfiguration.saveDividerLocationForFormName(elements.tabDetail.getTabFormNameAt(1));
   
   elements.tabSelection.removeAllTabs();
   elements.tabDetail.removeAllTabs();
   
   elements.vSplit.leftComponent = elements.tabSelection; // Restore 1st tabpanel assignment in case it has been set to null
   
   this.findForms = new Array(); // Forms to set into find mode when a find (Cmd-F) is done
   
   switch(menuId)
   {
      ...
      case 801:
      globals.createTabSelectionFooter('ScoSubjects', 0, 36);
      globals.createTabDetailFooter('ScoPersonsCapabilities', 0, 682);
      elements.tabSelection.addTab(forms.ScoSubjects, null, null, null, null, null, null);
      elements.tabDetail.addTab(forms.ScoPersonsCapabilities, null, null, null, null, null, null);
      break;
      ...
   }


Everytime, menu "801" is selected, the method globals.createTabSelectionFooter() is called (beside the other methods). The mothod looks like:

Code: Select all
function createTabSelectionFooter()
{
   /*
   Title:      The background image will be dynamically created with the solution model.
   
   Author:      Robert Huber
   Created:   01.09.2009
   Modified:   -
   
   Arguments:   String : Form to create footer part
            Integer : x position of button
            Integer : y position of button
   Returns:   -
   Notes:      The gradient background image paneFooterGradientBG.png will be appended to the right of existing buttons
   */
      
   var formName = arguments[0];
   var btnPosX = arguments[1];
   var btnPosY = arguments[2];

   // Remove form from history first to get a pre runtime state to add elements with the solution model to it (witout getting stale forms detected error)
   history.removeForm(formName); // Works!
   //solutionModel.removeForm(); // Doesn't work

   // Add background image paneFooterGradientBG.png to footer part
   var form = solutionModel.getForm(formName); // Get form to add footer element to   
   var paneFooter = form.newLabel(null, btnPosX, btnPosY, 220, 18);
   
   // Set properties for pane footer (gradient) graphic
   paneFooter.name = 'paneFooter';
   paneFooter.styleClass = 'Default';
   paneFooter.borderType = 'EmptyBorder, 0, 0, 0, 0';
   paneFooter.imageMedia = solutionModel.getMedia('paneFooterGradientBG.png');
   paneFooter.mediaOptions = SM_MEDIAOPTION.ENLARGE;
   paneFooter.anchors = SM_ANCHOR.WEST | SM_ANCHOR.SOUTH | SM_ANCHOR.EAST;
   paneFooter.showClick = false;
   paneFooter.showFocus = false;
}


So I still don't understand exactly why one works and the other doesn't.

Regards, Robert
Attachments
Picture 1.png
Picture 1.png (255.27 KiB) Viewed 5256 times
Robert Huber
7r gmbh, Switzerland
SAN Developer
www.seven-r.ch
User avatar
Robert Huber
 
Posts: 1239
Joined: Tue Aug 23, 2005 6:52 pm
Location: Schaffhausen, Switzerland

Re: Solution model exceptions

Postby jcompagner » Tue Sep 01, 2009 10:07 pm

form visible: if it is shown as the main form or in a visible tab.

blueprint: the solutionModel stuff. var form = solutionModel.getForm(formName) == blueprint, forms.formname == ui instance created from the blueprint.

Code: Select all
solutionModel.removeForm(formName); // Doesn't work
var form = solutionModel.getForm(formName); // Get form to add footer element to   


this is logical see my previous post.
If you call solutionModel.removeForm(formName)
then solutionModel.getForm(formName) will return null. Because you have removed the form from the blueprint. It is gone/deleted.

history.removeForm() will delete/remove the UI instance and then it can be recreated again from the forms blueprint.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Discuss Feature Requests

Who is online

Users browsing this forum: No registered users and 9 guests