tag:blogger.com,1999:blog-61406623530584454712024-03-26T21:44:18.816-07:00Mendix and the developerThe blog from a Mendix developer to Mendix developers. Giving possible solutions for problems or how Mendix works in certain situations.Anonymoushttp://www.blogger.com/profile/08700471609930803528noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6140662353058445471.post-31973366388277763752014-11-06T05:37:00.002-08:002014-11-09T23:21:49.775-08:00Mendix and Java heap: The start<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif; font-size: x-small;">Building apps with the Mendix platform is very easy. You create the domain models, microflows and pages and press start. Mendix will start everything what is needed to run your application. Mendix makes sure that all your data is stored in the database and it's available in your microflows. As a business engineer it's a great a simple platform.</span>
<br />
<br />
<span style="font-family: Verdana,sans-serif; font-size: x-small;">For the technical engineer I want to go a step further, because something makes Mendix run on the operating system. We all know that Mendix uses Java, an easy piece of middleware between Mendix and the OS. Java will handle the usage of memory and CPU on the OS. In my experience with Mendix the 'Out of Memory' exception is the most difficult one: an application that crashes on memory resources and isn't available any more. To understand how and why an OoM (Out of Memory exception) is triggered, we must first look how the Java memory works.</span>
<br />
<br />
<span style="font-family: Verdana,sans-serif; font-size: x-small;">The Java memory is divided in separate parts: young generation, old generation (the Java heap) and the permanent generation. The permanent generation is the memory place to load in all classes and libraries. Default it has a size 64Mb, but at Mendix it's on 128Mb, what is enough. The young and the old generation is the place what we're going to discuss. All objects that are in memory (non-persistent entities, microflow objects, page objects, etc.) are stored there. The ratio between the young and old generation is 1:3, so the old generation is 3 times bigger than the young generation. The young generation small but fast and the old is large but slow.</span>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiygqvcf6qT4ixpnyUTNvMJaexcmCvUIHdH1gMo6lJnsjgvNvx1n6zfO-62C4EMU3St5U0I1stzTGkaQj2pE_FdFZ5bg83ygzINLPufet_nJ7XahWDEodUBzYV9iS_ymPpmfWut4FqY1WI/s1600/JVM+Structure+1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiygqvcf6qT4ixpnyUTNvMJaexcmCvUIHdH1gMo6lJnsjgvNvx1n6zfO-62C4EMU3St5U0I1stzTGkaQj2pE_FdFZ5bg83ygzINLPufet_nJ7XahWDEodUBzYV9iS_ymPpmfWut4FqY1WI/s320/JVM+Structure+1.PNG" height="81" width="320" /></a></div>
<br />
<span style="font-family: Verdana,sans-serif; font-size: x-small;">When a microflow is started and is creating objects, the objects are pushed to the young generation. The generation keeps growing in size until it's reaching his max. At that point a minor garbage collection (short: minor GC) is triggered, removing all objects that aren't used anymore, making room for new objects. The minor GC doesn't take any resources, so you don't notice it's running. The objects that are still used, are of course saved. Those objects cannot be all the time in the young generation!</span>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9MFCnXmVTcc1Y-nQU59BlPra5ucnb7EaUl6DLF1OI-cu6lAhbmsuA2OpTy2Andro1WdJBP92gXIO0IUmS-iXq45ZrKGBH4UAlkIgAJuV1yqpCDq15RMuKqAEp2uUtZGbAG8Jh3KB3qpM/s1600/JVM+Structure+2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9MFCnXmVTcc1Y-nQU59BlPra5ucnb7EaUl6DLF1OI-cu6lAhbmsuA2OpTy2Andro1WdJBP92gXIO0IUmS-iXq45ZrKGBH4UAlkIgAJuV1yqpCDq15RMuKqAEp2uUtZGbAG8Jh3KB3qpM/s320/JVM+Structure+2.png" height="112" width="320" /></a></div>
<br />
<span style="font-family: Verdana,sans-serif; font-size: x-small;">When an object survives 2 minor garbage collections it will be transfer to the old generation. The old generation is bigger and holds more objects/data. It haves more impact when that generation needs to be cleaned: a major garbage collection (short: major GC). </span>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2XXt3mG2xDIgLKR2XXV0d4TQQkNRgKxaKhk66BefrT9TUJzakevfVaEi20n6PHBGBcn-lqId0edgACS3nTgrCYzcIYmaweDiQQrDqadCp_-uGWjMHd4TWtlo6YCFnYdqpjQquILyPQtE/s1600/JVM+Heap+Example.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2XXt3mG2xDIgLKR2XXV0d4TQQkNRgKxaKhk66BefrT9TUJzakevfVaEi20n6PHBGBcn-lqId0edgACS3nTgrCYzcIYmaweDiQQrDqadCp_-uGWjMHd4TWtlo6YCFnYdqpjQquILyPQtE/s320/JVM+Heap+Example.PNG" height="192" width="320" /></a></div>
<span style="font-family: Verdana,sans-serif; font-size: x-small;">At the graph above you see a Mendix app that is running about memory usage. The purple part is the young generation and the red is the old generation. Give a good look at the purple part, you see a saw structure, up and down. The red part is the old generation with 1 saw spike. Each time when the spike goes down a garbage collection is triggered. The minor GC happens a lot more than the major GC.</span>
<br />
<br />
<span style="font-family: Verdana,sans-serif; font-size: x-small;">Mendix uses Java with that memory setup. All objects that are created and used are stored, starting, in the young generation and after in the old generation. Each generation uses garbage collection to make room for new objects. This means that the garbage collection runs in iterations: fill up, GC, fill up, GC, etc.
<br />
In the next blogpost I will discuss how and why Out of Memory exception are triggered, viewing all kind of Java memory graphs. How to read those graphs and placing them in context with other graphs.</span>
</div>
Anonymoushttp://www.blogger.com/profile/08700471609930803528noreply@blogger.com5tag:blogger.com,1999:blog-6140662353058445471.post-11194871809961615492014-10-21T05:25:00.001-07:002014-10-21T05:25:28.111-07:00Rollback and associated objects<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">In a early <a href="http://mendixandthedeveloper.blogspot.nl/2013/10/autocommit-in-microflows.html" target="_blank">post</a> we've been talking about autocommitted objects in Mendix. Objects that have been automatically committed because of an association. But what do you do when then objects aren't used anymore? Actually delete or rollback the objects. </span></span><br />
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"> In the Domain Model you can set the delete behavior on associations. In the most cases the behavior is set to delete the associated objects as well. For each object Mendix will delete all objects that are associated. So with deleting one object you can delete a complete hierarchy of associated objects.</span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2yAc6uVgFNof0Md_BqgIFtgAkcuCoeF3KFQY9suR2U-vTX9HgAwCXDChXmxlk7_Bex_LDY3hKdRhQ4Q80wN-lOLZLiN5RaU7ssD6K1QWR-ijigcy8XcJITM2ntidjDNYCfr3bntwIAHQ/s1600/Association+behavoir.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2yAc6uVgFNof0Md_BqgIFtgAkcuCoeF3KFQY9suR2U-vTX9HgAwCXDChXmxlk7_Bex_LDY3hKdRhQ4Q80wN-lOLZLiN5RaU7ssD6K1QWR-ijigcy8XcJITM2ntidjDNYCfr3bntwIAHQ/s1600/Association+behavoir.PNG" height="200" width="190" /></a></div>
<br />
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">The delete behavior isn't only used for deleting objects, but also in a certain way for a rollback of an object. The setting is only used with a rollback of an instantiated object: a newly created object that haven't been committed yet. </span></span><br />
<br />
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">I've created a simple example project based on order management. The domain model is very simple with an 'Order', 'Orderline' and 'Products'. In testing the scenario the default Mendix functionality will be used, no custom created microflows. So the scenario: </span></span><br />
<ul>
<li><span style="font-family: Verdana,sans-serif; font-size: x-small;">An 'Order' is instantiated.</span></li>
<li><span style="font-family: Verdana,sans-serif; font-size: x-small;">Some 'Orderlines' are added and committed (the 'Order' will be autocommitted)</span></li>
<li><span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">The 'Order' will be cancelled: executing a rollback.</span></span></li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table style="text-align: center; width: 100%;">
<colgroup>
<col style="width: 50%;"></col>
<col style="width: 50%;"></col>
</colgroup>
<tbody>
<tr><td><span style="font-family: Verdana,sans-serif; font-size: x-small; font-weight: bold;">No association delete behavior</span></td>
<td><span style="font-family: Verdana,sans-serif; font-size: x-small; font-weight: bold;">With association delete behavior</span></td></tr>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoNUXRERkAtEELkOOYI1Y4_lCcvc3JStcdak5DSzgSEwHOaQdYiMLGZhef5ZQS3kVUgrbn0oJNa99F-wRJfLNdb6FMc0aSxB7Gy3G4KUSYpLGYHJa94VBVE7WDiWbTmEhU2a31S8-8mhY/s1600/Order+Domain+without.PNG" imageanchor="1" style="margin-bottom: 1em; margin-right: 1em;">
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoNUXRERkAtEELkOOYI1Y4_lCcvc3JStcdak5DSzgSEwHOaQdYiMLGZhef5ZQS3kVUgrbn0oJNa99F-wRJfLNdb6FMc0aSxB7Gy3G4KUSYpLGYHJa94VBVE7WDiWbTmEhU2a31S8-8mhY/s1600/Order+Domain+without.PNG" height="40" width="200" /></a>
</td>
<td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzOIqr9ttyY4PjUrr-ANL57caPKNYoCr2Wbq3N2uPlz4J8POSdHCZaC5Uwzp9brTmzCKicQFwBOkD8N1KTmhUV5N5YWrQyOz8n52E7NmlV12hrHBlgq0EFuGzt__iUsc_TQ2X5X7jwB74/s1600/Order+Domain.PNG" imageanchor="1" style="margin-bottom: 1em; margin-left: 1em;">
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzOIqr9ttyY4PjUrr-ANL57caPKNYoCr2Wbq3N2uPlz4J8POSdHCZaC5Uwzp9brTmzCKicQFwBOkD8N1KTmhUV5N5YWrQyOz8n52E7NmlV12hrHBlgq0EFuGzt__iUsc_TQ2X5X7jwB74/s1600/Order+Domain.PNG" height="41" width="200" /></a>
</td></tr>
<tr><td style="padding-right: 15px; text-align: justify;"><span style="font-family: Verdana,sans-serif; font-size: x-small;">The 'Order' has properly been cleared, nothing in my database, but the created 'Orderlines' are still be present.</span><br />
</td>
<td style="padding-left: 15px; text-align: justify;"><span style="font-family: Verdana,sans-serif; font-size: x-small;">The 'Orderlines' are perfectly deleted and I have never explicit deleted. Based on the association delete behavior Mendix will delete them on a rollback.</span></td></tr>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3syyeLXblhiAg9DGF9dhHly2zg4bIVJ0rDxjw7xMLnPg5o53c0PO5ZvgXnJZtvGxqeVtuJRRTp7x3MdvEL7mTK6m-8knjzGRU0P56ccd3DPoPBb0aJ_ZcN67P9SuhAPhvYaRtad6J8r4/s1600/Result+Without+order.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3syyeLXblhiAg9DGF9dhHly2zg4bIVJ0rDxjw7xMLnPg5o53c0PO5ZvgXnJZtvGxqeVtuJRRTp7x3MdvEL7mTK6m-8knjzGRU0P56ccd3DPoPBb0aJ_ZcN67P9SuhAPhvYaRtad6J8r4/s1600/Result+Without+order.PNG" height="50" width="200" /></a>
</td>
<td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFHlbdnULPJqBuqZZ61GlwW-Y60lAOZyBEUyffNUCbeW4SZqW132jf_65L8H5iKdRkkob9oJ8hM_s_DzPZ-wBDz9Pk2eIOAAgrDl_rQdKSETlUjloiMoEmRB2bXqxers7JLxi5qy8wJRk/s1600/Result+Without+orderlines.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFHlbdnULPJqBuqZZ61GlwW-Y60lAOZyBEUyffNUCbeW4SZqW132jf_65L8H5iKdRkkob9oJ8hM_s_DzPZ-wBDz9Pk2eIOAAgrDl_rQdKSETlUjloiMoEmRB2bXqxers7JLxi5qy8wJRk/s1600/Result+Without+orderlines.PNG" height="48" width="200" /></a>
</td></tr>
</tbody>
</table>
<br />
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">Summarizing: Mendix works with objects that are connected with associations. Mendix doesn't know the logic hierarchy of objects that we know and program. </span></span><span style="font-family: Verdana,sans-serif; font-size: x-small;">If Mendix has to delete or rollback an object it only occurs on that instance, other objects aren't changed. The delete behavior on associations is really important to have a clean database.</span></div>
Anonymoushttp://www.blogger.com/profile/08700471609930803528noreply@blogger.com0tag:blogger.com,1999:blog-6140662353058445471.post-47935568419296883812014-04-06T23:54:00.000-07:002014-04-09T23:08:17.167-07:00Mendixworld!<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">3 and 4 April Mendixworld is happening in the Cruise Terminal in Rotterdam. An event with </span></span><span style="font-family: Verdana, sans-serif; font-size: x-small;">18 sponsors and over 1500 registrations. Over </span><span style="font-family: Verdana, sans-serif; font-size: x-small;">50 speakers will come, 37 track sessions from customers, the Research and Development team, Expert Services and more. There is a lot to do for everyone. I will give you a short update of what is happened, but most of all, what will be released?</span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span></div>
<div style="text-align: center;">
<div class="separator" style="clear: both; font-family: Verdana,sans-serif; font-size: x-small;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoD0ikk-9G8rzxm87xBaGW9vIoociZmJq7waPJfD3VhblkXhj-CD0_cedUkc0ehXy_PyWb85DossUeIv8-iNnexOaaDxc9GK1mln6aKZUNSzepjF-iygtraH_GcIKDbdaKAnFS__dZvog/s640/blogger-image--1915434612.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoD0ikk-9G8rzxm87xBaGW9vIoociZmJq7waPJfD3VhblkXhj-CD0_cedUkc0ehXy_PyWb85DossUeIv8-iNnexOaaDxc9GK1mln6aKZUNSzepjF-iygtraH_GcIKDbdaKAnFS__dZvog/s320/blogger-image--1915434612.jpg" width="320" /></a></div>
</div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">First start: Derek Roos CEO of Mendix. His quote for his keynote: <a href="http://www.mendix.com/blog/mendix-ceo-every-company-software-company/" target="_blank">every company is becoming a software company</a>. Technology can disrupt a market and for you as company you need to be innovative and differential. Implementing new ideas and products for your customers. </span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">But more important for you: the new release. A big milestone in the Mendix products for developers, partners and end-users: "<a href="http://www.mendix.com/blog/march-2014-release/" target="_blank">Appcloud</a>"! Build, deploy and share apps. Everyone has ideas for new apps, workflows or business automation, but getting it to work and share it with your collegaes. Now it is possible with The Appcloud. How? It has three main features: launchpad, sandboxes and marketplace. </span></span></div>
<div style="text-align: justify;">
<h2>
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><b>Launchpad</b></span></span></h2>
</div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">One entry point for all your apps and open them with single sign-on service. Have an overview and bookmarks with the apps that you have within your company and your own creations. Just open and your logged in. But it goes further, start workflows, share documents and collaborate with your collegaes. Above all start your own project with the next feature: sandbox. </span></span></div>
<div style="text-align: justify;">
<h2>
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><b>Sandboxes</b></span></span></h2>
</div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">Each project will have his own sandbox cloud node. Create a project of your idea and deploy it in the Mendix cloud. Your application is direct available from your launchpad and share and build it with your collegaes. So you can test your app direct in a cloud environment. Because it is in your launchpad it will have single sign-on for all the users. So can you have a free cloud node, yes, with limitations. The app is limited to 10 users and won't be active all the time. After 1 hour inactivity the cloud node will go to sleep, but it will go live in 40 seconds after you access the URL. All your data will be saved and accessible for your users. But sometimes you don't have an idea to implement and there is a great feature for you!</span></span></div>
<div style="text-align: justify;">
<h2>
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><b>Marketplace</b></span></span></h2>
</div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;">A new upgraded App store that will have more content and completely workable project that can de downloaded. You can open a project within the App Store and deploy it in a sandbox with just three mouse clicks. The project will be downloaded and deployed in a teamserver so you can invite people to build the app and start implementing ideas. Beside downloading a project you van view the project in a running cloud environment. </span></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: xx-small;">This is Appcloud a big step in bringing ideas to apps. All features will go live next April the 10th. So this is the first day of Mendix world. </span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><br /></span></span>
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><a href="http://www.mendix.com/mendix-world-2014/" target="_blank">Mendix world 2014</a></span></span><br />
<span style="font-size: x-small;"><span style="font-family: Verdana,sans-serif;"><a href="http://www.mendix.com/blog/march-2014-release/" target="_blank">Release of Appcloud</a></span></span></div>
Anonymoushttp://www.blogger.com/profile/08700471609930803528noreply@blogger.com0Kop van Zuid, Rotterdam, The Netherlands51.906016962036929 4.487013816833496151.905404462036927 4.4857533168334962 51.906629462036932 4.488274316833496tag:blogger.com,1999:blog-6140662353058445471.post-20911901924382699752014-03-21T05:46:00.000-07:002014-04-02T23:36:30.854-07:00Build custom validation messages<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;">It has been a while I've added a new post. I've been moving to a new house. Some weeks later I've been come a father of a beautiful boy. So I hope you will forgive me for the late post. That being said, let's get back to Mendix and build great apps. Off course I will build mine examples in Mendix 5.</span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span>
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;">The consistency of your data is of great importance of your business processes. If a part of data isn't correct, it can come corrupt with all consequences</span><span style="font-size: x-small;">. On the other hand you want to use conditional visibility in your pages. The user must only see the fields what he needs to fill in. </span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglFKkTiOY89rTglweNhWNWbwYkP8txKs1ufSsdsHvZg9FUCABXn2SRZRQPn9ZakfUEGHU_UgzGR5XYBHYuKdjc_p1QkG-QRs6B-MlbSGkFvJ8CAdRTatjmhzvYBK2qjJTkrjbRekN6yek/s1600/Required+Field.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglFKkTiOY89rTglweNhWNWbwYkP8txKs1ufSsdsHvZg9FUCABXn2SRZRQPn9ZakfUEGHU_UgzGR5XYBHYuKdjc_p1QkG-QRs6B-MlbSGkFvJ8CAdRTatjmhzvYBK2qjJTkrjbRekN6yek/s1600/Required+Field.PNG" height="161" width="320" /></a></span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;">With Mendix you can add default validation checks on fields. Those only work when you don't use </span><span style="font-size: x-small;">conditional visibility. When you set the property '</span><span style="font-size: x-small;">required' on a field that is placed on a row that is conditional visible, Mendix will generate the error: "</span><span style="font-size: x-small;">Widget may not be required if the containing table row is conditionally visible." To implement validation checks on pages that contain conditional visibility it must be done with microflows.</span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;">In this example I use a page to edit a product: Product_NewEdit. The product can be of two types: Stockitem and Service. Based on that selection the user needs to fill in other types of data. The save of the product is handled by a microflow. The best practice to implement validation is the usage of a sub-microflow (a microflow that is called by a microflow). </span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;">I create one microflow to validate a product: "SF_Product_Validation" and let the micrflow return a boolean: valid or not. The best way to start is to make a boolean variable that will used as the return value of the microflow. The boolean start with the value "true", we assume that the user gives the right information. Along the way of the microflow each attribute is checked and according how the conditional visibility is build in the page, the visible attributes are checked.</span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1mkJMYYojvYpITXPg9AI9IUwkC0yHHRJL1JYMtyitT8Tg_lEGOEY9dO7aMeXK4LZNsknJWFL42hTw-NfIUMlDV3sBYKsB6C7bsjGilPkBofJgMEV_RZptF67HX2r0FRxAd56Td13xEg4/s1600/SF_Product_Validation.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1mkJMYYojvYpITXPg9AI9IUwkC0yHHRJL1JYMtyitT8Tg_lEGOEY9dO7aMeXK4LZNsknJWFL42hTw-NfIUMlDV3sBYKsB6C7bsjGilPkBofJgMEV_RZptF67HX2r0FRxAd56Td13xEg4/s1600/SF_Product_Validation.png" height="113" width="320" /></a></span></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;">But why the use of a sub-microflow? To create an easier way for maintenance and possibility for unit testing. The best way to build microflows is by creating them in single functions, just like programming for example in Java. Microflows become testable for example unit testing. </span></span></div>
<table><thead>
<tr><th style="text-align: justify;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></th><th style="text-align: justify;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></th><th style="text-align: justify;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></th><th style="text-align: justify;"><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></th><th><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></th><th><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></th></tr>
</thead><tbody>
<tr><td><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></td><td><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></td><td><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></td><td><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></td><td><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></td><td><span style="font-family: Verdana,sans-serif;"><span style="font-size: x-small;"><br /></span></span></td></tr>
</tbody></table>
Anonymoushttp://www.blogger.com/profile/08700471609930803528noreply@blogger.com0tag:blogger.com,1999:blog-6140662353058445471.post-53420829924002258172013-10-19T02:47:00.003-07:002014-04-02T23:37:23.723-07:00Autocommit in microflows<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: x-small;">At my first post I discussed a custom constrained by, by using a Microflow as a datasource. In the example I used an Order management and created a new "Orderline". I want to go on this example and discuss how Mendix works with a phenomenon "Autocommit". </span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: x-small;">I'm going to save the new "OrderLine" with a Microflow trigger on the Form "OrderLine_NewEdit". Because it is a Microflow, it will not trigger the standard textbox validations. I have to build the validation myself. When the "OrderLine" is valid, I retrieve the "Order" from the association and calculate the total order price. Then the "OrderLine" is committed and the Form is closed.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjztCSZxXHny1VBzjY_Vm1rZVWvKuiCTxRK71JqwoJOmFqZrSvf4x73cwbrab8klDfik4E7CQuaU2NKLXFOCqo9pj2vniQ6EVyy1RXEKPbnMhldq1PNHlg47oE_hp_r4JAUZsfABaXoVGM/s1600/Microflow+Orderline+Save.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjztCSZxXHny1VBzjY_Vm1rZVWvKuiCTxRK71JqwoJOmFqZrSvf4x73cwbrab8klDfik4E7CQuaU2NKLXFOCqo9pj2vniQ6EVyy1RXEKPbnMhldq1PNHlg47oE_hp_r4JAUZsfABaXoVGM/s1600/Microflow+Orderline+Save.png" height="95" width="400" /></a></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: x-small;">When I debug the Microflow and look at the state of each object before and after committing the "OrderLine", something occurs. In the first step the "Order" as the "OrderLine" has the state "instantiated". The second step the "OrderLine" is committed to the database and gets the state "normal". The "Order" however has the state "autocommitted".</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgffmlnubDds3tmqhyTFT1Czgcsr3qcNmEuG7pl671gpfbw86QpCNP64mylYE_s-K6e-doaKhGHbAL58JFGxASS_VIufXKR5hKbcHTWXKOJQiNLLltsLnDvjThCiIcQZ0lZBTCAErbJR0k/s1600/Microflow+debug+autocommit.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgffmlnubDds3tmqhyTFT1Czgcsr3qcNmEuG7pl671gpfbw86QpCNP64mylYE_s-K6e-doaKhGHbAL58JFGxASS_VIufXKR5hKbcHTWXKOJQiNLLltsLnDvjThCiIcQZ0lZBTCAErbJR0k/s1600/Microflow+debug+autocommit.PNG" height="214" width="320" /></a></span></div>
<div style="text-align: justify;">
<span style="font-size: x-small;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: x-small;">When the "OrderLine" is committed to the database, the association to the "Order" is also committed. In the database it isn't possible to refer to an object that doesn't exist. So Mendix inserts the "Order" and gives it the state "</span><span style="font-family: Verdana, sans-serif; font-size: x-small;">autocommitted</span><span style="font-family: Verdana, sans-serif; font-size: x-small;">". Based on this Mendix knows that cancelling the object must lead to a delete in the database, because it was't committed explicit by any logic.</span></div>
<div style="text-align: justify;">
<ul style="text-align: start;">
<li style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: x-small;">Instantiated: A new object that is only present in the application memory.</span></li>
<li style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: x-small;">Normal: An object that is present in the database.</span></li>
<li style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: x-small;">Autocommitted: An object inserted in the database by an association.</span></li>
</ul>
<div>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><a href="http://www.mendix.com/community/resources/getting-started/" target="_blank">Get started with Mendix</a></span></div>
<div>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><a href="https://world.mendix.com/display/refguide4/Change+Object" target="_blank">Mendix documentation</a></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/08700471609930803528noreply@blogger.com0tag:blogger.com,1999:blog-6140662353058445471.post-84661621857153909832013-10-12T03:27:00.001-07:002014-04-02T23:36:57.367-07:00Reference selector with special constrainted by<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: x-small;">My first post:</span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;">We all have sometimes the situation that we have to commit an object, because the retrieval of data for an reference selector will not work. The data depends on the selection of something else but the selection isn't of the same object. For example we have a form for an "Orderline" what contains the reference selector for the "Product". Here comes the tricky part, it may only be that "Product" that belongs to a "Category" selected in the "Order". The domain model can looks likes this.</span></div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEo0W4J40140_byjTa8_igetsKKLdy8b-fZiBQSe8hSNDyCcH_cim5iOszoxal9qEIk_Ui5d1kYJRAm706rvntKxPLU2Ke3n606Mvw1fqv0tfF4bbCYXqnP3GbsIpfHQgbBaq1IquTBzU/s1600/ODM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEo0W4J40140_byjTa8_igetsKKLdy8b-fZiBQSe8hSNDyCcH_cim5iOszoxal9qEIk_Ui5d1kYJRAm706rvntKxPLU2Ke3n606Mvw1fqv0tfF4bbCYXqnP3GbsIpfHQgbBaq1IquTBzU/s1600/ODM.png" height="220" width="400" /></a></span></div>
<span style="font-family: Verdana, sans-serif; font-size: x-small;">In the modeler you can select the "Constraint by" property on a reference selector to let Mendix automatic constraint the data based on the associations. But in this case the "Order" is a new object and not committed to the database, so the results for the "Product" reference selector is empty. </span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCE_RO6DFzVYnMlbsrjafJtw2Sk8w8aMZtpjr4rEi0l320koNmpEzmCUcj41CSJ_u5bb2Jb5WXp8Vh-_UQ3xxxG2xw5TmrabWXm4U6UTgTHz03h9txGKe8OBTvZ8qje2ADfXoIbKRCdSM/s1600/Constraint+example.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCE_RO6DFzVYnMlbsrjafJtw2Sk8w8aMZtpjr4rEi0l320koNmpEzmCUcj41CSJ_u5bb2Jb5WXp8Vh-_UQ3xxxG2xw5TmrabWXm4U6UTgTHz03h9txGKe8OBTvZ8qje2ADfXoIbKRCdSM/s1600/Constraint+example.png" height="285" width="400" /></a></span></div>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;">The reason for the missing data has to do how the constraint by function works. The constraint by function works for the first association, in this case "ODM.OrderLine_Order", and the other associations needs to be in the database, except the last one. The association "ODM.Order_Category" was not in the database and therefor the results were empty.</span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span>
<span style="font-family: Verdana, sans-serif; font-size: x-small;">To solve this issue isn't to be committing the "Order" object before adding a new "OrderLine", but to use a datasource Microflow for the Reference Selector. In that Microflow you can retrieve the "Order" over association (from the memory of Mendix). Than retrieve all products that are attached to category based on the association of "ODM.Order_Category". You just don't have to retrieve the "Category" object first.</span><br />
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj40ozv8BMyAh1iGA95IHp3SSdaOV7q3-DbZozjr7dLeoLqd-9mCJMEDTe-H1PfMzGQZ7RSEwlDn15p7-fVdcJ9rPV_aZ6HD5kzcvNj3lTa9DKXoNzRkBY4fFbUnZCGF21G7AdTb8Ulhas/s1600/DS_Products.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj40ozv8BMyAh1iGA95IHp3SSdaOV7q3-DbZozjr7dLeoLqd-9mCJMEDTe-H1PfMzGQZ7RSEwlDn15p7-fVdcJ9rPV_aZ6HD5kzcvNj3lTa9DKXoNzRkBY4fFbUnZCGF21G7AdTb8Ulhas/s1600/DS_Products.png" height="135" width="400" /></a></span></div>
<span style="font-family: Verdana, sans-serif; font-size: x-small;"><br /></span></div>
Anonymoushttp://www.blogger.com/profile/08700471609930803528noreply@blogger.com2