<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: how to set the mandatory property dynamically?</title><link>https://answers.axonivy.com/questions/443/how-to-set-the-mandatory-property-dynamically</link><description>&lt;p&gt;I need to set the &lt;code&gt;mandatory&lt;/code&gt; property of some widgets at the run-time depending on some run time criteria and without having a typed reference to the widget. How can I do this?&lt;/p&gt;
&lt;p&gt;I can do this for example for the &lt;code&gt;visible&lt;/code&gt; property. I can loop through all components of a display or other panel or container by &lt;code&gt;panel.myContainer.getComponents()&lt;/code&gt;, select which components I am interested in and then call &lt;code&gt;setVisible(Boolean)&lt;/code&gt; on them.&lt;/p&gt;
&lt;p&gt;I cannot call &lt;code&gt;setMandatory(Boolean)&lt;/code&gt; on this level but I would need to. &lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/443/how-to-set-the-mandatory-property-dynamically" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 29 Mar 2012 05:13:46 -0400</lastBuildDate><item><title>Answer by Philipp Haslinger</title><link>https://answers.axonivy.com/questions/443/how-to-set-the-mandatory-property-dynamically/444</link><description>&lt;p&gt;The problem is that &lt;code&gt;panel.getComponents()&lt;/code&gt; returns a list of ULC components. The validation with the &lt;code&gt;mandatory&lt;/code&gt; property is an improvement from ivyTeam which is not accessible on ULC level.&lt;/p&gt;
&lt;p&gt;The solution would be to cast the ULC component to concrete type of widgets and then call &lt;code&gt;setMandatory(Boolean)&lt;/code&gt; on the casted object.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for(Object object : panel.GridBagLayoutPane.getComponents()) 
{
    if(object instanceof RTextField) 
    {
        (object as RTextField).setMandatory(true);
    }
}
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Philipp Haslinger</dc:creator><pubDate>Thu, 29 Mar 2012 05:13:46 -0400</pubDate><guid>https://answers.axonivy.com/questions/443/how-to-set-the-mandatory-property-dynamically/444</guid></item></channel></rss>