🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16268

Re: getting referance to a component

#16268
From: Gerry Mantha
Date: Sun, 14 Mar 1999 00:00
56 lines
3343 bytes
Ok, so you want to implement some new "security policy" behavior for UI
controls. The key so solving this problem is thinking about what behavior is
being changed for what.  What this all comes down to, is that:

1.    It is the GUI Controls that must modify their behavior
2.    The GUI Controls must have access to a security policy defined for
them

Since you wish to add specialized behavior to the Controls, start by
subclassing them.  Your security policy seems to be implemented at the
finest grain level (field level), so each control must have access to a
central location where it can decide for itself whether it must be disabled
or enabled.  This is relatively easy.  After the user signs on to your
system, read in the policy information from your database, and stick it in
hashtable lying in a static class that all controls can have access to.  In
your subclassed control, you add a setter/getter method for the name-mapping
that is in your database.  In your client code (Like in your frame) you just
mySecurityTextField.setSecurityName("whatever");

You can also override the addNotify() method of your control, and have it
lookup it's securityName in your static security class, which will return
perhaps a boolean on whether it should be enabled or not, and does so.

This is probably the simplest, although not the most graceful method of
implementing a generic security policy for your application.  There are many
more fancy methods that are much cooler, but rather more complicated.
Perhaps the biggest problem with your approach to the problem lies in tying
object names to string names kept in a database.  Keep the behavior
modifications in the object that requires modification, and avoid object
naming dependancies at all costs.  Remember, someone would have had to keep
this database security info and object names in sync (Poor guy!)

Hope this helps,

Gerry Mantha


Kiran Deshpande wrote in message <36D598A8.EA158C7A@incentric.com>...
>Hi,
>    I wanted to find out if and how to get a referance to a text field
>in a Frame/dialog if I have the name of the field as a String. Here is
>what I want to do:
>    In my application I want to disable or enable a field depending on
>the group a user belongs to.  So, if I had all the fields and the
>permissions for them in the database and retrieve it.  Now I want to get
>a referance to the component (lets say a text field) defined in my frame
>or dialog which is declared with the same name as the field name in the
>database.  I dont want to hard code this into my program and want to
>make it generic so that I send in the name of the field (as string) and
>set the enabled property of the component.
>    Is there a way to do it?  Or do I have to go by hard coding this
>functionality.
>
>Thanks & Regards
>Kiran
>
Technical Details
Message-ID: <7ch6nr$122@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36D598A8.EA158C7A@incentric.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,5d6bb407908f3a97
X-Google-Attributes: gidf74b3,public
From: "Gerry Mantha" <gmantha@home.com>
Subject: Re: getting referance to a component
Date: 1999/03/14
Message-ID: <7ch6nr$122@forums.borland.com>
X-Deja-AN: 454960739
References: <36D598A8.EA158C7A@incentric.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
Organization: QTECH Hybrid Systems Inc.
Newsgroups: borland.public.jbuilder.java.language