Re: Custom Component Id Other than Class Name

2012-10-14 Thread Lance Java
If you knew what you were doing, you could decorate the
ComponentClassResolver. Warning: experts only ;)
I suggest you download the tapestry sources and take a look at
ComponentClassResolverImpl before attempting this.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Custom-Component-Id-Other-than-Class-Name-tp5716882p5716884.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Custom Component Id Other than Class Name

2012-10-13 Thread Dragan Sahpaski
I guess it's possible that you put components into different "virtual
folders"/packages and then make different library mapping names for
them.
http://tapestry.apache.org/component-libraries.html#ComponentLibraries-Step4%3AConfigurethevirtualfolder

Cheers,
Dragan Sahpaski


On Sun, Oct 14, 2012 at 12:04 AM, Bob Obringer  wrote:
> I've created a library of custom Tapestry components and have been unable to 
> figure out how to use an ID other than class name to reference those 
> components.
>
> The library I'm creating is part of a much larger framework and as such I 
> have requirements for class names.  These names are not what I would like to 
> use for the component ID and I've searched everywhere for a way to customize 
> the ID.
>
> I assume the answer I'm looking for will be "no it's not possible" or "yes, 
> here's a simple solution" but have been unable to find that answer.
>
>
> Thanks,
>
> Bob Obringer
> Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
>

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Custom Component - @BeforeRenderBody not rendering stuff

2012-04-02 Thread Chris Mylonas
Thanks

My "source" (and whatever the iterator returns) are always null...so I'll have 
to find out why that happens.

On 02/04/2012, at 10:14 PM, Lance Java wrote:

> Tapestry's own loop component might give you some inspiration too
> http://tapestry.apache.org/5.3/apidocs/src-html/org/apache/tapestry5/corelib/components/Loop.html
> 
> 
> On Monday, 2 April 2012, Lance Java  wrote:
>> 
>> Perhaps this diagram will help to debug
> http://tapestry.apache.org/component-rendering.html
>> 
>> On Monday, 2 April 2012, Chris Mylonas  wrote:
>>> Hi Tapestry List,
>>> 
>>> After spending a few hours with render phases and all that comes with it
> (heartbeat/resources) I'm in a bit of a jam that I don't know where to go
> next.
>>> I'm setting up a basic component called PhoneView that receives an
> ArrayList of Phone objects...similar to the Tree example on the wiki [1]
>>> 
>>> @CleanupRender & @BeforeRenderBody have the same code to make it easy
> for the beginner (me!) to see his progress...
>>> There are 2 items in the array list I have created using a BeanEditForm,
> so I presume I should see three lots of the div saying "CHRIS! This is your
> amazing test div - " with the render phase name.  (2 x BeforeRenderBody) +
> (1 x CleanupRender).
>>> 
>>> I'm not :(
>>> 
>>> Running your eye over this code/template...can you help me?
>>> 
>>> 
>>>   /**
>>>* Defines the source of the phones
>>>*/
>>>   @Parameter(required = true)
>>>   private ArrayList source ;
>>> 
>>>   /**
>>>* Iterator to go over the source (Phone) elements
>>>*/
>>>   private Iterator iterator;
>>> 
>>>   /**
>>>*
>>>*/
>>>   @Inject
>>>   private ComponentResources resources ;
>>> 
>>>   /**
>>>*
>>>*/
>>>   @Parameter
>>>   private Phone currentPhone ;
>>> 
>>>   /**
>>>*
>>>*/
>>>   @Parameter(defaultPrefix = BindingConstants.LITERAL)
>>>   private Block empty;
>>> 
>>>   /**
>>>*
>>>*/
>>>   @Environmental
>>>   private Heartbeat heartbeat ;
>>> 
>>>   /**
>>>* @return
>>>*/
>>>   @SetupRender
>>>   boolean SetupRender(){
>>>if( source == null ){
>>>return false ;
>>>}
>>>this.iterator = source.iterator();
>>>return (iterator.hasNext());
>>>   }
>>> 
>>>   @BeginRender
>>>   void beginRender(){
>>>   currentPhone = iterator.next();
>>>   heartbeat.begin();
>>>   }
>>> 
>>>   @BeforeRenderBody
>>>   void beforeRenderBody(MarkupWriter writer){
>>> 
>>>   Element cur = writer.element("div",
>>> 
> "class","userbackground").addClassName("adifferentbackground");
>>>   cur.text("CHRIS! This is your amazing test div -
> beforeRenderBody");
>>>   writer.end();
>>> 
>>> 
>>>   resources.renderInformalParameters(writer);
>>>   }
>>>   /**
>>>* @return
>>>*/
>>>   @AfterRender
>>>   boolean afterRender(){
>>>   heartbeat.end();
>>>   return (!iterator.hasNext());
>>>   }
>>> 
>>>   /**
>>>* @param writer
>>>*/
>>>   @CleanupRender
>>>   void cleanupRender(MarkupWriter writer){
>>>   Element cur = writer.element("div",
>>> 
> "class","userbackground").addClassName("adifferentbackground");
>>>   cur.text("CHRIS! This is your amazing test div -
> cleanupRender");
>>>   writer.end();
>>>   }
>>> 
>>> 
>>> And the tml snippet from Index.tml
>>> 
>>> 
>>> 
>>> Add Phone
>>> 
>>> Chris 1
>>> 
>>> 
>>> 
>>> Chris 2
>>> 
>>> 
>>> 
>>> Thanks
>>> Chris
>>> 
>>> 
>>> 
>>> [1] =
> https://wiki.apache.org/tapestry/Tapestry5HowToCreateYourOwnComponents


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Custom Component - @BeforeRenderBody not rendering stuff

2012-04-02 Thread Lance Java
Tapestry's own loop component might give you some inspiration too
http://tapestry.apache.org/5.3/apidocs/src-html/org/apache/tapestry5/corelib/components/Loop.html


On Monday, 2 April 2012, Lance Java  wrote:
>
> Perhaps this diagram will help to debug
http://tapestry.apache.org/component-rendering.html
>
> On Monday, 2 April 2012, Chris Mylonas  wrote:
>> Hi Tapestry List,
>>
>> After spending a few hours with render phases and all that comes with it
(heartbeat/resources) I'm in a bit of a jam that I don't know where to go
next.
>> I'm setting up a basic component called PhoneView that receives an
ArrayList of Phone objects...similar to the Tree example on the wiki [1]
>>
>> @CleanupRender & @BeforeRenderBody have the same code to make it easy
for the beginner (me!) to see his progress...
>> There are 2 items in the array list I have created using a BeanEditForm,
so I presume I should see three lots of the div saying "CHRIS! This is your
amazing test div - " with the render phase name.  (2 x BeforeRenderBody) +
(1 x CleanupRender).
>>
>> I'm not :(
>>
>> Running your eye over this code/template...can you help me?
>>
>>
>>/**
>> * Defines the source of the phones
>> */
>>@Parameter(required = true)
>>private ArrayList source ;
>>
>>/**
>> * Iterator to go over the source (Phone) elements
>> */
>>private Iterator iterator;
>>
>>/**
>> *
>> */
>>@Inject
>>private ComponentResources resources ;
>>
>>/**
>> *
>> */
>>@Parameter
>>private Phone currentPhone ;
>>
>>/**
>> *
>> */
>>@Parameter(defaultPrefix = BindingConstants.LITERAL)
>>private Block empty;
>>
>>/**
>> *
>> */
>>@Environmental
>>private Heartbeat heartbeat ;
>>
>>/**
>> * @return
>> */
>>@SetupRender
>>boolean SetupRender(){
>> if( source == null ){
>> return false ;
>> }
>> this.iterator = source.iterator();
>> return (iterator.hasNext());
>>}
>>
>>@BeginRender
>>void beginRender(){
>>currentPhone = iterator.next();
>>heartbeat.begin();
>>}
>>
>>@BeforeRenderBody
>>void beforeRenderBody(MarkupWriter writer){
>>
>>Element cur = writer.element("div",
>>
 "class","userbackground").addClassName("adifferentbackground");
>>cur.text("CHRIS! This is your amazing test div -
beforeRenderBody");
>>writer.end();
>>
>>
>>resources.renderInformalParameters(writer);
>>}
>>/**
>> * @return
>> */
>>@AfterRender
>>boolean afterRender(){
>>heartbeat.end();
>>return (!iterator.hasNext());
>>}
>>
>>/**
>> * @param writer
>> */
>>@CleanupRender
>>void cleanupRender(MarkupWriter writer){
>>Element cur = writer.element("div",
>>
 "class","userbackground").addClassName("adifferentbackground");
>>cur.text("CHRIS! This is your amazing test div -
cleanupRender");
>>writer.end();
>>}
>>
>>
>> And the tml snippet from Index.tml
>>
>> 
>> 
>> Add Phone
>> 
>> Chris 1
>> 
>> 
>> 
>> Chris 2
>>
>>
>>
>> Thanks
>> Chris
>>
>>
>>
>> [1] =
https://wiki.apache.org/tapestry/Tapestry5HowToCreateYourOwnComponents


Re: Custom Component - @BeforeRenderBody not rendering stuff

2012-04-02 Thread Lance Java
Perhaps this diagram will help to debug
http://tapestry.apache.org/component-rendering.html

On Monday, 2 April 2012, Chris Mylonas  wrote:
> Hi Tapestry List,
>
> After spending a few hours with render phases and all that comes with it
(heartbeat/resources) I'm in a bit of a jam that I don't know where to go
next.
> I'm setting up a basic component called PhoneView that receives an
ArrayList of Phone objects...similar to the Tree example on the wiki [1]
>
> @CleanupRender & @BeforeRenderBody have the same code to make it easy for
the beginner (me!) to see his progress...
> There are 2 items in the array list I have created using a BeanEditForm,
so I presume I should see three lots of the div saying "CHRIS! This is your
amazing test div - " with the render phase name.  (2 x BeforeRenderBody) +
(1 x CleanupRender).
>
> I'm not :(
>
> Running your eye over this code/template...can you help me?
>
>
>/**
> * Defines the source of the phones
> */
>@Parameter(required = true)
>private ArrayList source ;
>
>/**
> * Iterator to go over the source (Phone) elements
> */
>private Iterator iterator;
>
>/**
> *
> */
>@Inject
>private ComponentResources resources ;
>
>/**
> *
> */
>@Parameter
>private Phone currentPhone ;
>
>/**
> *
> */
>@Parameter(defaultPrefix = BindingConstants.LITERAL)
>private Block empty;
>
>/**
> *
> */
>@Environmental
>private Heartbeat heartbeat ;
>
>/**
> * @return
> */
>@SetupRender
>boolean SetupRender(){
> if( source == null ){
> return false ;
> }
> this.iterator = source.iterator();
> return (iterator.hasNext());
>}
>
>@BeginRender
>void beginRender(){
>currentPhone = iterator.next();
>heartbeat.begin();
>}
>
>@BeforeRenderBody
>void beforeRenderBody(MarkupWriter writer){
>
>Element cur = writer.element("div",
>
 "class","userbackground").addClassName("adifferentbackground");
>cur.text("CHRIS! This is your amazing test div -
beforeRenderBody");
>writer.end();
>
>
>resources.renderInformalParameters(writer);
>}
>/**
> * @return
> */
>@AfterRender
>boolean afterRender(){
>heartbeat.end();
>return (!iterator.hasNext());
>}
>
>/**
> * @param writer
> */
>@CleanupRender
>void cleanupRender(MarkupWriter writer){
>Element cur = writer.element("div",
>
 "class","userbackground").addClassName("adifferentbackground");
>cur.text("CHRIS! This is your amazing test div -
cleanupRender");
>writer.end();
>}
>
>
> And the tml snippet from Index.tml
>
> 
> 
> Add Phone
> 
> Chris 1
> 
> 
> 
> Chris 2
>
>
>
> Thanks
> Chris
>
>
>
> [1] =
https://wiki.apache.org/tapestry/Tapestry5HowToCreateYourOwnComponents


Re: Custom component

2011-10-06 Thread Giulio Micali
yes, the second is better If your component is a "container" for a group of
fields.
In that case, you should do it in the afterRender phase, so your method is
called after all single fields has already the new submitted values and you
can "validate" (and rollback if you want) the whole result.


2011/10/3 Rendy Tapestry 

> Thanks Taha,
>
> I'll give your second suggestion a try.
>
> Thanks,
> Rendy.
>
> On Sun, Oct 2, 2011 at 11:03 PM, Taha Hafeez Siddiqi <
> tawus.tapes...@gmail.com> wrote:
>
> > Hi Rendy
> >
> > Your component, if fits the definition of a form field, can extend
> > AbstractField and then override processSubmission() method.
> >
> > Otherwise you can @Inject FormSupport and then use
> > FormSupport#storeAndExecute() to execute a ComponentAction
> >
> > regards
> > Taha
> >
> > On Oct 2, 2011, at 9:18 PM, Rendy Tapestry wrote:
> >
> > > Hi All,
> > >
> > > Is it possible to have a custom component with a method that will
> getting
> > > called when the enclosing form is being submitted ? In that method, I
> > want
> > > to change some parameter of that custom component.
> > >
> > > Thanks,
> > > Rendy.
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>


Re: Custom component

2011-10-02 Thread Rendy Tapestry
Thanks Taha,

I'll give your second suggestion a try.

Thanks,
Rendy.

On Sun, Oct 2, 2011 at 11:03 PM, Taha Hafeez Siddiqi <
tawus.tapes...@gmail.com> wrote:

> Hi Rendy
>
> Your component, if fits the definition of a form field, can extend
> AbstractField and then override processSubmission() method.
>
> Otherwise you can @Inject FormSupport and then use
> FormSupport#storeAndExecute() to execute a ComponentAction
>
> regards
> Taha
>
> On Oct 2, 2011, at 9:18 PM, Rendy Tapestry wrote:
>
> > Hi All,
> >
> > Is it possible to have a custom component with a method that will getting
> > called when the enclosing form is being submitted ? In that method, I
> want
> > to change some parameter of that custom component.
> >
> > Thanks,
> > Rendy.
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Custom component

2011-10-02 Thread Taha Hafeez Siddiqi
Hi Rendy

Your component, if fits the definition of a form field, can extend 
AbstractField and then override processSubmission() method.

Otherwise you can @Inject FormSupport and then use 
FormSupport#storeAndExecute() to execute a ComponentAction

regards
Taha
 
On Oct 2, 2011, at 9:18 PM, Rendy Tapestry wrote:

> Hi All,
> 
> Is it possible to have a custom component with a method that will getting
> called when the enclosing form is being submitted ? In that method, I want
> to change some parameter of that custom component.
> 
> Thanks,
> Rendy.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Custom Component Problem

2008-07-01 Thread Sven Homburg
mark your parameters with @Persist like this:

@Persist
@Property
private Long myParameter;

@Component(parameters = {"value=myParameter"})
private MyCustomComponent blablub

2008/7/1 MichaƂ U <[EMAIL PROTECTED]>:

>
> Hi,
>
> I am quite new to tapestry and I found a problem with custom component.
> How can I make parameters of my component persistent? When I reload the
> page
> I change value of page properties bound to those parameters. In my
> component
> I still habe same value as when the page have been loaded for the first
> time.
>
> I know that It probably has a very easy solution, but I lost few hours and
> haven't come up with any solution.:-(
>
> Thanks for your help in advance:handshake:
> --
> View this message in context:
> http://www.nabble.com/Custom-Component-Problem-tp18219551p18219551.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com


Re: Custom Component - best solution?

2006-09-05 Thread jake123

Thank you Ed for your fast answer. This looks like it solve all my problems

//Jacob

-- 
View this message in context: 
http://www.nabble.com/Custom-Component---best-solution--tf2220888.html#a6156680
Sent from the Tapestry - User forum at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Custom Component - best solution?

2006-09-05 Thread Ed Ross

you might want to take a look at

http://www.tapestrycomponents.org/Tassel/app?service=external/ViewComponent&sp=SJSCookMenu

for some existing menus and how this could be accomplished.

On 9/5/06, jake123 <[EMAIL PROTECTED]> wrote:



Hi, I am trying to create a custom component that will create a menu and
submenus to that menu on a completly dynamic web page. The entire site are
build up with "components" and I get the entire structure from the
database.
In the web layer I have a Object called SiteDTO that looks like this:

/* PRIVATE MEMBERS */
private List regionDTOList = new
ArrayList();
private List menuIdList = new ArrayList();

private Map menuItemMap = new HashMap();
private Map menuDTOMap = new HashMap();
private Map articleMap = new HashMap();
private Map articleListDTOMap = new
HashMap();
private Map portletMap = new HashMap();

all have getters and setters.  My menuIdList contains the id value that is
the key in my menuDTOMap.

my MenuDTO.java is much simpler and looks like this

/* PRIVATE MEMBERS */
private Menu menu;
private List menuItemIdList = new ArrayList();

each menuDTO have a menuItemIdList containing the id that is the key value
in SiteDTO.menuItemMap.

I need to iterate through the first menuIdList and for each menuId pull
the
MenuDTO from MenuDTOMap. For each menuDTO I need to take the menuItemList
and iterate over that list to pull the MenuItem object that I need to
desplay in the html page along with the corresponding menu object.

How do I solve this the best way? I am thinking of creating a custom
component for this but I am kind of new to Tapestry and I could really
need
some good pointers. Should I try to iterate through this structure in the
page file or shall I do it in my component.java file? Is there any pros
and
cons for the different approach?

Thanks
Jacob

--
View this message in context:
http://www.nabble.com/Custom-Component---best-solution--tf2220888.html#a6152304
Sent from the Tapestry - User forum at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Ed Ross
[EMAIL PROTECTED]


RE: Custom component validation - two fields

2006-06-04 Thread Mark Stang
Ryan,
Glad you figured out your problem.

regards,

Mark


-Original Message-
From: Ryan Cuprak [mailto:[EMAIL PROTECTED]
Sent: Sat 6/3/2006 10:34 PM
To: Tapestry users
Subject: Re: Custom component validation - two fields
 

  Hello,
  I think figured out my problem - I needed to render the html  
template in rewindFormComponent! It was right in front of me the  
entire time.

  -Ryan

On Jun 3, 2006, at 3:40 PM, Ryan Cuprak wrote:

>
>  I think I follow. So you only display the TextField if the  
> checkbox was checked (via refresh submit)?
>  I plowed ahead with trying to implement my own  
> AbstractFormComponent that would use an html template and also  
> render some of its own content. However, I am getting a stale link  
> exception when I submit. Either I am setting something up  
> incorrectly or missing the boat on the rewind. Not exactly sure how  
> to parse the StaleLink page. Been diving through the list archives  
> and source trying to get a better idea on how component ids are  
> generated and the rewind is done.
>  I can create a new form component re-using other form components -  
> right?
>  To read the template I yanked code out of the BaseComponent class.
>
>  In the end, I want my custom component to display a checkbox and a  
> textfield (possibly a PropertySelection as well). When the form is  
> submitted, if the checkbox is checked but no content is contained  
> in the textfield I want to decorate it and add a message to the  
> top. This component will be used at least a dozen time on the page  
> for different search parameters.
>
>  Gradually learning!
>
>  Thanks,
>  Ryan
>
>
> Exception:
> ---
> You have clicked on a stale link.
>
> Rewind of form test/testForm expected 1 more form elements,  
> starting with id 'selected'.
>
> This is most likely the result of using your browser's back button,  
> but can also be an application error.
>
> Component Java code:
> ---
> public abstract class ComboTest extends AbstractFormComponent  
> implements ITemplateComponent {
>
> private static Logger logger = Logger.getLogger(ComboTest.class);
>
> private static final int OUTER_INIT_SIZE = 5;
> private IRender[] _outer;
> private int _outerCount = 0;
>
> public ComboTest() {
>
> }
>
> public abstract boolean isSelected();
>
> public void readTemplate(IRequestCycle cycle, IPageLoader  
> loader) {
> loader.loadTemplateForComponent(cycle,this);
> }
>
> protected void  renderFormComponent(IMarkupWriter writer,  
> IRequestCycle cycle) {
> logger.debug("being combotest render");
> // this was an attempt to solve it, thought maybe it was  
> missing the id for this component (this didn't work.)
> writer.begin("input");
> writer.attribute("type","hidden");
> writer.attribute("name",getName());
> writer.attribute("id",getName());
> writer.end();
> for(int i =0; i < _outerCount; i++) {
> _outer[i].render(writer,cycle);
> }
>
> logger.debug("end combotest render");
> }
>
> protected void rewindFormComponent(IMarkupWriter writer,  
> IRequestCycle cycle) {
> logger.debug("combotest choosen: choosen: " +  
> cycle.getParameter(getName()));
>
> }
>
> public void finishLoad(IRequestCycle cycle , IPageLoader  
> loader , IComponentSpecification specification) {
> logger.debug("finishing load");
> readTemplate(cycle,loader);
> super.finishLoad(cycle,loader,specification);
> }
>
> public void addOuter(IRender element) {
> logger.debug("outer being rendered");
> if(_outer == null) {
> _outer = new IRender[OUTER_INIT_SIZE];
> _outer[0] = element;
> _outerCount = 1;
> return;
> }
> if (_outerCount == _outer.length) {
> IRender[] newOuter;
> newOuter = new IRender[_outer.length*2];
> System.arraycopy(_outer,0,newOuter,0,_outerCount);
> _outer = newOuter;
> }
> _outer[_outerCount++] = element;
> }
> }
>
> HTML Template:
> ---
> 
> 
> Test
> 
> 
> 
> 
> 
>
> Template:
> ---
>  class="com.kodak.mis.web.components.ComboTest"
>  allow-informal-parameters="yes"
>  allow-body="no">
> 
> 
> 
> 
>
>
> On Friday, June 02, 2006, 

Re: Custom component validation - two fields

2006-06-03 Thread Ryan Cuprak


 Hello,
 I think figured out my problem - I needed to render the html  
template in rewindFormComponent! It was right in front of me the  
entire time.


 -Ryan

On Jun 3, 2006, at 3:40 PM, Ryan Cuprak wrote:



 I think I follow. So you only display the TextField if the  
checkbox was checked (via refresh submit)?
 I plowed ahead with trying to implement my own  
AbstractFormComponent that would use an html template and also  
render some of its own content. However, I am getting a stale link  
exception when I submit. Either I am setting something up  
incorrectly or missing the boat on the rewind. Not exactly sure how  
to parse the StaleLink page. Been diving through the list archives  
and source trying to get a better idea on how component ids are  
generated and the rewind is done.
 I can create a new form component re-using other form components -  
right?

 To read the template I yanked code out of the BaseComponent class.

 In the end, I want my custom component to display a checkbox and a  
textfield (possibly a PropertySelection as well). When the form is  
submitted, if the checkbox is checked but no content is contained  
in the textfield I want to decorate it and add a message to the  
top. This component will be used at least a dozen time on the page  
for different search parameters.


 Gradually learning!

 Thanks,
 Ryan


Exception:
---
You have clicked on a stale link.

Rewind of form test/testForm expected 1 more form elements,  
starting with id 'selected'.


This is most likely the result of using your browser's back button,  
but can also be an application error.


Component Java code:
---
public abstract class ComboTest extends AbstractFormComponent  
implements ITemplateComponent {


private static Logger logger = Logger.getLogger(ComboTest.class);

private static final int OUTER_INIT_SIZE = 5;
private IRender[] _outer;
private int _outerCount = 0;

public ComboTest() {

}

public abstract boolean isSelected();

public void readTemplate(IRequestCycle cycle, IPageLoader  
loader) {

loader.loadTemplateForComponent(cycle,this);
}

protected void  renderFormComponent(IMarkupWriter writer,  
IRequestCycle cycle) {

logger.debug("being combotest render");
// this was an attempt to solve it, thought maybe it was  
missing the id for this component (this didn't work.)

writer.begin("input");
writer.attribute("type","hidden");
writer.attribute("name",getName());
writer.attribute("id",getName());
writer.end();
for(int i =0; i < _outerCount; i++) {
_outer[i].render(writer,cycle);
}

logger.debug("end combotest render");
}

protected void rewindFormComponent(IMarkupWriter writer,  
IRequestCycle cycle) {
logger.debug("combotest choosen: choosen: " +  
cycle.getParameter(getName()));


}

public void finishLoad(IRequestCycle cycle , IPageLoader  
loader , IComponentSpecification specification) {

logger.debug("finishing load");
readTemplate(cycle,loader);
super.finishLoad(cycle,loader,specification);
}

public void addOuter(IRender element) {
logger.debug("outer being rendered");
if(_outer == null) {
_outer = new IRender[OUTER_INIT_SIZE];
_outer[0] = element;
_outerCount = 1;
return;
}
if (_outerCount == _outer.length) {
IRender[] newOuter;
newOuter = new IRender[_outer.length*2];
System.arraycopy(_outer,0,newOuter,0,_outerCount);
_outer = newOuter;
}
_outer[_outerCount++] = element;
}
}

HTML Template:
---


Test






Template:
---
class="com.kodak.mis.web.components.ComboTest"

 allow-informal-parameters="yes"
 allow-body="no">






On Friday, June 02, 2006, at 12:38PM, Mark Stang  
<[EMAIL PROTECTED]> wrote:


What we do is to wrap the checkbox in an AnySubmit.  And then when  
checked a submit happens and the field is then displayed with  
whatever mark-up is required.  If the user attempts to leave the  
screen standard edits tell them they need to provide a value.  If  
they uncheck the box, the field goes away.  Basically, it is done  
via a Conditional or Choose Component.


hth,

Mark


-Original Message-
From: Ryan Cuprak [mailto:[EMAIL PROTECTED]
Sent: Fri 6/2/2006 12:38 PM
To: users@tapestry.apache.org
Subject: Custom component validation - two fields

Hello,
We are trying to implement a rather simple custom form component  
for a search page and perform validation on it. The custom  
component has a checkbox and a text field. If the checkbox is  
checked then a value must be provided in the text field. If not,  
the field must be decorated and a message displayed at the top of  
the form (tie in with the delegate etc). What is the recom

RE: Custom component validation - two fields

2006-06-03 Thread Ryan Cuprak
 
 I think I follow. So you only display the TextField if the checkbox was 
checked (via refresh submit)?
 I plowed ahead with trying to implement my own AbstractFormComponent that 
would use an html template and also render some of its own content. However, I 
am getting a stale link exception when I submit. Either I am setting something 
up incorrectly or missing the boat on the rewind. Not exactly sure how to parse 
the StaleLink page. Been diving through the list archives and source trying to 
get a better idea on how component ids are generated and the rewind is done.
 I can create a new form component re-using other form components - right?
 To read the template I yanked code out of the BaseComponent class. 

 In the end, I want my custom component to display a checkbox and a textfield 
(possibly a PropertySelection as well). When the form is submitted, if the 
checkbox is checked but no content is contained in the textfield I want to 
decorate it and add a message to the top. This component will be used at least 
a dozen time on the page for different search parameters. 
 
 Gradually learning!

 Thanks,
 Ryan


Exception:
---
You have clicked on a stale link.

Rewind of form test/testForm expected 1 more form elements, starting with id 
'selected'.

This is most likely the result of using your browser's back button, but can 
also be an application error.  

Component Java code:
---
public abstract class ComboTest extends AbstractFormComponent implements 
ITemplateComponent {

private static Logger logger = Logger.getLogger(ComboTest.class);

private static final int OUTER_INIT_SIZE = 5;
private IRender[] _outer;
private int _outerCount = 0;

public ComboTest() {

}

public abstract boolean isSelected();

public void readTemplate(IRequestCycle cycle, IPageLoader loader) {
loader.loadTemplateForComponent(cycle,this);
}

protected void  renderFormComponent(IMarkupWriter writer, IRequestCycle 
cycle) {
logger.debug("being combotest render");
// this was an attempt to solve it, thought maybe it was missing the id 
for this component (this didn't work.)
writer.begin("input");
writer.attribute("type","hidden");
writer.attribute("name",getName());
writer.attribute("id",getName());
writer.end();
for(int i =0; i < _outerCount; i++) {
_outer[i].render(writer,cycle);
}

logger.debug("end combotest render");
}

protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle 
cycle) {
logger.debug("combotest choosen: choosen: " + 
cycle.getParameter(getName()));

}

public void finishLoad(IRequestCycle cycle , IPageLoader loader , 
IComponentSpecification specification) {
logger.debug("finishing load");
readTemplate(cycle,loader);
super.finishLoad(cycle,loader,specification);
}

public void addOuter(IRender element) {
logger.debug("outer being rendered");
if(_outer == null) {
_outer = new IRender[OUTER_INIT_SIZE];
_outer[0] = element;
_outerCount = 1;
return;
}
if (_outerCount == _outer.length) {
IRender[] newOuter;
newOuter = new IRender[_outer.length*2];
System.arraycopy(_outer,0,newOuter,0,_outerCount);
_outer = newOuter;
}
_outer[_outerCount++] = element;
}
}

HTML Template:
---


Test






Template:
---





 

On Friday, June 02, 2006, at 12:38PM, Mark Stang <[EMAIL PROTECTED]> wrote:

>What we do is to wrap the checkbox in an AnySubmit.  And then when checked a 
>submit happens and the field is then displayed with whatever mark-up is 
>required.  If the user attempts to leave the screen standard edits tell them 
>they need to provide a value.  If they uncheck the box, the field goes away.  
>Basically, it is done via a Conditional or Choose Component.
>
>hth,
>
>Mark
>
>
>-Original Message-
>From: Ryan Cuprak [mailto:[EMAIL PROTECTED]
>Sent: Fri 6/2/2006 12:38 PM
>To: users@tapestry.apache.org
>Subject: Custom component validation - two fields
> 
>Hello, 
> We are trying to implement a rather simple custom form component for a search 
> page and perform validation on it. The custom component has a checkbox and a 
> text field. If the checkbox is checked then a value must be provided in the 
> text field. If not, the field must be decorated and a message displayed at 
> the top of the form (tie in with the delegate etc). What is the recommended 
> approach for implementing such component validation? Must we extend 
> AbstractFormComponent and implement the renderFormComponent or is there a 
> simpler approach? Is there a hybrid AbstractFormComponent/BaseComponent we 
> have missed somehow? 
>
> Thanks!
> Ryan
>
>-
>To unsubscribe, e-mail: [

RE: Custom component validation - two fields

2006-06-02 Thread Mark Stang
What we do is to wrap the checkbox in an AnySubmit.  And then when checked a 
submit happens and the field is then displayed with whatever mark-up is 
required.  If the user attempts to leave the screen standard edits tell them 
they need to provide a value.  If they uncheck the box, the field goes away.  
Basically, it is done via a Conditional or Choose Component.

hth,

Mark


-Original Message-
From: Ryan Cuprak [mailto:[EMAIL PROTECTED]
Sent: Fri 6/2/2006 12:38 PM
To: users@tapestry.apache.org
Subject: Custom component validation - two fields
 
Hello, 
 We are trying to implement a rather simple custom form component for a search 
page and perform validation on it. The custom component has a checkbox and a 
text field. If the checkbox is checked then a value must be provided in the 
text field. If not, the field must be decorated and a message displayed at the 
top of the form (tie in with the delegate etc). What is the recommended 
approach for implementing such component validation? Must we extend 
AbstractFormComponent and implement the renderFormComponent or is there a 
simpler approach? Is there a hybrid AbstractFormComponent/BaseComponent we have 
missed somehow? 

 Thanks!
 Ryan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]