I think a clearer explanation would be that in most instances you shouldn't
have to directly interact with components in java code. There are special
cases, but for the most part there is probably a better way to do whatever
it is that you are doing.

What is the problem you are trying to solve that involves getting access to
all of these components?

On 3/7/06, Leo Sakhvoruk <[EMAIL PROTECTED]> wrote:
>
> Thanks Alan, but what if there are 10+ components as in my case? It
> would be pretty cumbersome to inject every single one of them.
>
> Alan Chandler wrote:
>
> >On Tuesday 07 March 2006 20:11, Leo Sakhvoruk wrote:
> >
> >
> >>Hi everyone,
> >>
> >>I'm trying to manipulate components inside a form and am having trouble
> >>casting them correctly. What class should components be cast to since
> >>they're enhanced?
> >>
> >>
> >
> >I found the easiest way is to inject them as per this example
> >
> >
> >       @InjectComponent("newrole")
> >       public abstract TextField getNewRoleField();
> >
> >       public void updateRoles() {
> >               if (getButtonClicked() < 0) {
> >                       /*
> >                        * Create a new role
> >                        */
> >                       ValidRole vr = getNewRole();
> >                       if (!(vr.getName() == null || 
> > vr.getName().equals("")))
> {
> >                               try{
> >                                       vr.create();
> >                               } catch (DatabaseException e) {
> >                                       ValidationDivDelegate delegate =
> getDelegate();
> >                                       delegate.setFormComponent
> (getNewRoleField());
> >
> >delegate.record(getMessages().getMessage("error.naming"),
> ValidationConstraint.CONSISTENCY);
> >                                       return;
> >                               }
> >                               setNewRole(null);  //Clear out the field
> so its not detected next time
> >                       }
> >               }
> >       }
> >}
> >
> >
> >
> >
>
>

Reply via email to