Thanx for this snippet. In the end, in a validator the trick to obtaining the ComponentResources turned out as simple as casting the Field object to a Component and using getComponentResources(). Allas it didn't seem to work from there on. Even though I manage to plow my way through the Components to find the right Component that's supposed to match, I have to date not been able to obtain its' value.
However, this all is knowledge that will certainly come in handy :) Gr, Martin On 6/14/07, Todd Orr <[EMAIL PROTECTED]> wrote:
The quick and dirty is this: Given: The targetId String of the related component passed into this component as a parameter: resources is an injected instance of ComponentResources like so @Inject private ComponentResources resources; Code: Component comp = resources.getPage().getComponentResources() .getEmbeddedComponent(targetId); if (!(comp instanceof SearchResults)) { throw new IllegalArgumentException( "targetId is not an instance of SearchResults"); } return (SearchResults) comp; Hope that helps. On 6/13/07, Martin Reurings <[EMAIL PROTECTED]> wrote: > Can you give me some small example code on how you were able to gain access > from one tag to the other? I am currently trying to create a matchfield > validator in which one text field must match the value of another and I am > pondering on how to access the second field. > > I know the id of the second field (in theory), all I need to know is how to > obtain access to the other field (apart from cheating my way out by > accessing the httprequest I suppose). > > Regards, > > Martin > > On 6/13/07, Todd Orr <[EMAIL PROTECTED]> wrote: > > > > I have created a solution that requires the developer to add a > > targetId parameter to the SearchForm component that specifies the ID > > of the SearchResults component. This is sort of how Label works with > > an input component. It currently requires the literal: prefix on the > > String targetId passed to it. > > > > This was easy enough. I suppose this is the correct way. > > > > On 6/12/07, Todd Orr <[EMAIL PROTECTED]> wrote: > > > How would one create two components that function by one passing the > > > results of some form processing to another? > > > > > > My use case is this: I have a reusable SearchForm component. This > > > component is little more than a form that takes the search parameter > > > and executes the search using the OnEvent annotated method. I have a > > > second component, SearchResults. This component is currently a simple > > > wrapper around a grid for proof of concept. I would like to keep these > > > separate so that the page using these components can easily alter the > > > locations of the components, page logic, etc. with as little concern > > > for the enclosed components as possible. > > > > > > I'd like to set the SearchResults' source parameter to that of the > > > results of the SearchForm's submit event processing. I have yet to > > > create anything that works. What is the T5 recommended approach for > > > this desired case? > > > > > > Thanks, > > > T > > > > >