You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vinicius Carvalho <ja...@gmail.com> on 2006/08/10 17:06:44 UTC
Component Design questions
Hello there! First, I'm sorry about the previous e-mail, I really
thought that the name was being duplicated :(. Sorry for the spam
I got stuck into a problem here. I'm building my datetime component.
First I thought using a template for it, but later I figured that I
needed to extend AbstractFormComponent, and this can not have a
template right?
This is how my component looks like:
<component-specification
class="com.synos.pbh.chat.view.components.DateTime" allow-body="yes"
allow-informal-parameters="yes">
<description>
Simple Date and Time Component
</description>
<parameter name="displayName">
<description>
The name of the field, which may be used by a FieldLabel.
</description>
</parameter>
<parameter name="validators"/>
<parameter name="style" required="no"
default-value="literal:input"></parameter>
<parameter name="value" required="yes"></parameter>
<component id="days" type="PropertySelection">
<binding name="model" value="daysInMonth"></binding>
<binding name="value" value="selectedDay"></binding>
<binding name="name" value="ognl:getNestedName('days')"></binding>
</component>
<component id="months" type="PropertySelection">
<binding name="model" value="months"></binding>
<binding name="value" value="selectedMonth"></binding>
</component>
<component id="years" type="PropertySelection">
<binding name="model" value="years"></binding>
<binding name="value" value="selectedYear"></binding>
</component>
<component id="hours" type="TextField">
<binding name="value" value="inputHour"></binding>
</component>
<component id="minutes" type="TextField">
<binding name="value" value="inputMinute"></binding>
</component>
<inject property="validatableFieldSupport"
object="service:tapestry.form.ValidatableFieldSupport"/>
<inject property="translatedFieldSupport"
object="service:tapestry.form.TranslatedFieldSupport"/>
</component-specification>
Ok, as you can see my component is composed of 4 other components, I
thought that would be easier than write them all using IRequestWriter
(mostly the PropertySelection ones :P )
But that was working fine for a component with a template, I've faced
some problems with this new approach, the first is the way I render
the component:
protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle) {
if(getValue() != null){
assignValues();
}
Iterator it = getComponents().keySet().iterator();
while(it.hasNext()){
IComponent component = (IComponent)getComponents().get(it.next());
component.render(writer, cycle);
}
}
Well it does render the components, but I'd like to add some informal
parameters for each (like style, size, min/max lengths)
So here goes the first question, how do I do this?
Second is regarding the rewindFormComponent phase:
protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle) {
GregorianCalendar cal = new
GregorianCalendar(Integer.parseInt(getSelectedYear()),Integer.parseInt(getSelectedMonth()),Integer.parseInt(getSelectedDay()),Integer.parseInt(getInputHour()),Integer.parseInt(getInputMinute()));
setValue(cal);
}
Well, this does not work, I was expecting the abstract getters to be
filled by my component, of course I was wrong, misunderstood the whole
component life-cycle (again :P ).
Now I'm facing another huge problem (at least on my point of view)
I've changed the method to this:
protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle) {
String day = cycle.getParameter(getComponent("days").getId());
String month = cycle.getParameter(getComponent("months").getId());
String year = cycle.getParameter(getComponent("months").getId());
String hour = cycle.getParameter(getComponent("hours").getId());
String minute = cycle.getParameter(getComponent("minutes").getId());
}
Having two of this components on my pages gives me twice nested
components like (days, days_0, months, months_0 and so on). So I tried
the method above hopping that for each component, I could set the
correct value. Once again I was wrong, What I get now is:
Rewind of form cadastrarEvento/cadastroForm expected allocated id #7
to be 'days', but was 'dataTermino' (requested by component
cadastrarEvento/dataTermino).
Well, to explain, my dateTime component (I have two on the page, the
first is called dataInicio and the second DataTermino) I guess I had a
problem when trying to rewind the second component, it seems that my
nested components got the ID that the parent had.
So this is the second question, how do I solve this?
Please any directions would be mostly appreciated
Best regards
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org