#1
|
|||
|
|||
mandatory attribute
Hi all !!!
I have another question for you . I'm working whit "Change Class" window; is there a way to make mandatory an attribute in this window? I mean, I would like that, when I click 'OK' in this windows and the save proces starts, if there is some attribute with null value or empty string value the save process stops end returns an error message. I hope I'm not confused !!! Thank's in advanced, Nadia |
#2
|
|||
|
|||
Re: mandatory attribute
There are a couple of ways to make required attributes. The easiest way is to create a data dictionary for the attribute that requires a value. This requires no coding and has the added bennifit in that in release 14.20 or later, required attributes are marked with a star (*).
If the required values or more complicated than can be expressed by data dictionaries, you could write a PreApplyListener. PreApplyListeners are called just before an element is applied to the database and allow you to verify values. If something is wrong, you just throw and exception and the text of the exception is shown as an error message to the user. |
#3
|
|||
|
|||
Re: mandatory attribute
thank a lot for your suggestion :-) !!
I used PreApplyListeners xml tag, and now I can control if the attribute of masterdata in null. But now I have another question for you; how can descover if an object (a Part) is a part of a Group? I saw that there is a coloum in data base table that tells us if a Part is a PartAssembly but if no, how can get if the part is in such grups? thank in advanced :-) , Nadia |
#4
|
|||
|
|||
Re: mandatory attribute
Do you mean "is this part an assembly?". If so you could ask the part for its children and test to see if any of the children are parts. However, asking for children may cause queries to the database which can greatly affect performance.
For example: private boolean isPartAnAssembly(Part part) throws WMException { boolean b = false; List<WMElement> children = part.getChildren(); //may query! for(WMElement child : children) { if (child instanceof Part) { b = true; break; } } return b; } |
#5
|
||||
|
||||
Re: mandatory attribute
Hi,
If you would like to know if an Masterdata belongs to an assembly, you can use an existing method m.isAssembly() where m is an instance of a DMMasterdata object. Kind Regards, John
__________________
High performance CAD workstations Please visit us at https://www.cadware.nl |
#6
|
|||
|
|||
Re: mandatory attribute
Thank's for your answers.
now I can discover if a part of a Group belongs to an assembly, but i have to do some controls only in the 'DB Property' window. I kwon that the attribute editor associate to an attribute, is being called each time the attribute be must load: so in the 'DB Property' window, in 'Change Class' window, and so on ... How I can do this? Than's for your help, Nadia |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|