So when I was using Angular JS, I wanted to set the form in a modal dialog window back to its pristine state whenever it was shown.

Problem was, the form is always undefined. If I place a code within the modal window, the form exists but when I call it in a Javascript function, it is undefined.

The solution is to add $parent to your form name like this:

This will automatically create the form object in your parent controller. Then, you can simply access it using the scope like $scope.myForm.

Before Angular JS, my idea of a cascading dropdown select would be to some dropdown components in my HTML page and loading the children based on its parent.

With Angular JS, I would recommend you avoid this style. Why create so 2 dropdown controls when you can have only one and show the options in a tree like structure together with its parent?

If your hierarchy involves more than 2 levels, you can easily create a directive for it.

For simplicity’s sake, rather than showing 2 dropdown controls and changing the second dropdown based on the parent chosen in the first dropdown, you can use the “group by” keyword in the ng-option attribute of the SELECT tag.

Think of “group by” the same way you do in SQL. Pretty easy, right?

A sample code would be:

To set a JDialog to modal and attach it to a parent window, a parameter has to be passed as JFrame. However, suppose you show a JDialog from a JApplet? Casting it to JFrame will result in an Exception.

Its other constructor parameters are either java.awt.Dialog or java.awt.Window which, from a Swing standpoint should not be mixed with heavyweight components.

Luckily, with JDK 1.6 the SwingUtilities class has a method that can return the window component for any component that you pass as the parameter.

Related Posts Plugin for WordPress, Blogger...