You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Patrick Casey <pa...@adelphia.net> on 2005/06/02 03:52:36 UTC
Manipulating existing components via java code
I have a component on my form:
<input type="text" jwcid="@TextField" value="ognl:object.login"
size="30"/>
I have some java code that runs on a button handler:
Public void edit(IRequestCycle cycle) {
If (some complicated server side processing) {
// give the field a color code based on the result
of the processing
// this gets the field (or seems to)
Map m = this.getPage().getComponents();
Iterator it = m.values().iterator();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof IComponent) {
IComponent c = (IComponent) o;
// reload the component to get a
modifiable version
c =
getPage().getComponent(c.getId());
// snipped out some more processing
to make sure I'm on the right widget
// ok, now how to make it red?
c.setProperty("class", "red"); //
exception
}
}
}
}
How the heck do I make the component red? I can make it red on the
page definition with:
<input type="text" jwcid="@TextField" value="ognl:object.login"
class="red" size="30"/>
But I can't seem to find a way for my java code to set the class
programmatically. Is there a way I can do this?
--- pat
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Manipulating existing components via java code
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jun 1, 2005, at 9:52 PM, Patrick Casey wrote:
>
> I have a component on my form:
>
> <input type="text" jwcid="@TextField" value="ognl:object.login"
> size="30"/>
>
> How the heck do I make the component red? I can make it red on
> the
> page definition with:
>
> <input type="text" jwcid="@TextField" value="ognl:object.login"
> class="red" size="30"/>
>
> But I can't seem to find a way for my java code to set the class
> programmatically. Is there a way I can do this?
You could use ValidField instead, mark the field with a validation
error programatically, and then have it automatically styled with the
ValidationDelegate (or more likely a custom one).
Erik
p.s. I'm looking forward to Paul's improvements in the validation arena!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: Manipulating existing components via java code
Posted by Patrick Casey <pa...@adelphia.net>.
Hmmm... that might work; thanks.
--- Pat
> -----Original Message-----
> From: Bryan Lewis [mailto:bryan@maine.rr.com]
> Sent: Wednesday, June 01, 2005 7:02 PM
> To: Tapestry users
> Subject: Re: Manipulating existing components via java code
>
> How about something like this?
>
> <input jwcid="@TextField" class="ognl:textClass" ... />
>
> java:
>
> public String getTextClass()
> {
> return "redtitle";
> }
>
>
>
> ----- Original Message -----
> From: "Patrick Casey" <pa...@adelphia.net>
> To: "'Tapestry users'" <ta...@jakarta.apache.org>
> Sent: Wednesday, June 01, 2005 9:52 PM
> Subject: Manipulating existing components via java code
>
>
> >
> > I have a component on my form:
> >
> > <input type="text" jwcid="@TextField" value="ognl:object.login"
> > size="30"/>
> >
> > I have some java code that runs on a button handler:
> >
> > Public void edit(IRequestCycle cycle) {
> > If (some complicated server side processing) {
> > // give the field a color code based on the result
> > of the processing
> > // this gets the field (or seems to)
> > Map m = this.getPage().getComponents();
> > Iterator it = m.values().iterator();
> > while (it.hasNext()) {
> > Object o = it.next();
> > if (o instanceof IComponent) {
> > IComponent c = (IComponent) o;
> > // reload the component to get a
> > modifiable version
> > c =
> > getPage().getComponent(c.getId());
> > // snipped out some more processing
> > to make sure I'm on the right widget
> > // ok, now how to make it red?
> > c.setProperty("class", "red"); //
> > exception
> >
> >
> > }
> > }
> > }
> > }
> >
> > How the heck do I make the component red? I can make it red on the
> > page definition with:
> >
> > <input type="text" jwcid="@TextField" value="ognl:object.login"
> > class="red" size="30"/>
> >
> > But I can't seem to find a way for my java code to set the class
> > programmatically. Is there a way I can do this?
> >
> > --- pat
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Manipulating existing components via java code
Posted by Bryan Lewis <br...@maine.rr.com>.
How about something like this?
<input jwcid="@TextField" class="ognl:textClass" ... />
java:
public String getTextClass()
{
return "redtitle";
}
----- Original Message -----
From: "Patrick Casey" <pa...@adelphia.net>
To: "'Tapestry users'" <ta...@jakarta.apache.org>
Sent: Wednesday, June 01, 2005 9:52 PM
Subject: Manipulating existing components via java code
>
> I have a component on my form:
>
> <input type="text" jwcid="@TextField" value="ognl:object.login"
> size="30"/>
>
> I have some java code that runs on a button handler:
>
> Public void edit(IRequestCycle cycle) {
> If (some complicated server side processing) {
> // give the field a color code based on the result
> of the processing
> // this gets the field (or seems to)
> Map m = this.getPage().getComponents();
> Iterator it = m.values().iterator();
> while (it.hasNext()) {
> Object o = it.next();
> if (o instanceof IComponent) {
> IComponent c = (IComponent) o;
> // reload the component to get a
> modifiable version
> c =
> getPage().getComponent(c.getId());
> // snipped out some more processing
> to make sure I'm on the right widget
> // ok, now how to make it red?
> c.setProperty("class", "red"); //
> exception
>
>
> }
> }
> }
> }
>
> How the heck do I make the component red? I can make it red on the
> page definition with:
>
> <input type="text" jwcid="@TextField" value="ognl:object.login"
> class="red" size="30"/>
>
> But I can't seem to find a way for my java code to set the class
> programmatically. Is there a way I can do this?
>
> --- pat
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org