Re: Unable to get clientId in a component [T5.3.8]

2017-01-09 Thread Cezary Biernacki
Hi,

I can't see the actual .tml, as either it was stripped by the mailer or you
forgot to include it. But I guess compareDateRangeFrom component is in .tml
after dateRangePresent component, and Tapestry not yet allocated a client
ID for it. Generating client IDs is a bit complicated in Tapestry as a
single Tapestry component can be rendered multiple times (e.g. in loops).
There is "heartbeat" mechanism, that helps to solve such problems, e.g. see
Tapestry's Label implementation. Try following approach:

@Import(library = "DateRangePreset.js")
void afterRender() {
 renderLater();
}

@HeartbeatDeferred
private void renderLater() {

JSONObject specs = new JSONObject();
specs.put("select", "#" + dateRangePresetSelect.getClientId());
specs.put("dateRangeFrom", "#" + dateRangeFrom.getClientId());
logger.info("ff: " + relatedRangeFrom);

if (relatedRangeFrom != null) {
logger.info("rel: " + relatedRangeFrom.getClientId());
// specs.put("relatedRangeFrom", "#" +
relatedRangeFrom.getClientId());
specs.put("relatedRangeFrom", "#compareDateRangeFrom");
}

}


Best regards,
Cezary



On Mon, Jan 9, 2017 at 9:24 PM, Tony Nelson  wrote:

> I’m trying to build a simple component that references up to 4 components
> on my page.
>
> I’m using the component like this:
>
>
>  t:dateRangeFrom="dateRangeFrom"
> t:dateRangeTo="dateRangeTo"
> t:relatedRangeTense="FUTURE"
> t:relatedRangeFrom="compareDateRangeFrom"
> t:relatedRangeTo="compareDateRangeTo"
> t:disableDateRangePeriodTypes="DAILY"
> t:disableDateRangeTense="FUTURE" />
>
>
> dateRangeFrom, dateRangeTo are both required in the component, and work
> fine
>
> @Parameter(required = true, defaultPrefix = BindingConstants.COMPONENT)
> private Field dateRangeFrom;
>
> @Parameter(required = true, defaultPrefix = BindingConstants.COMPONENT)
> private Field dateRangeTo;
>
> relatedRangeFrom and relatedRangeTo are non-null, in after render, and
> they are the right type, but the clientId always returns null
>
> @Parameter(required = false, defaultPrefix =
> BindingConstants.COMPONENT)
> private Field relatedRangeFrom;
>
> @Parameter(required = false, defaultPrefix =
> BindingConstants.COMPONENT)
> private Field relatedRangeTo;
>
>
> afterRender() does the normal things
>
> @Import(library = "DateRangePreset.js")
> void afterRender() {
>
> JSONObject specs = new JSONObject();
> specs.put("select", "#" + dateRangePresetSelect.getClientId());
> specs.put("dateRangeFrom", "#" + dateRangeFrom.getClientId());
> logger.info("ff: " + relatedRangeFrom);
>
> if (relatedRangeFrom != null) {
> logger.info("rel: " + relatedRangeFrom.getClientId());
> // specs.put("relatedRangeFrom", "#" +
> relatedRangeFrom.getClientId());
> specs.put("relatedRangeFrom", "#compareDateRangeFrom");
> }
>
> }
>
> In the log I see
>
> [INFO ][DateRangePreset] ff: org.apache.tapestry5.corelib.
> components.DateField@46490fee
> [INFO ][DateRangePreset] rel: null
>
>
> The only thing that’s different between the required DateFields and the
> optional ones, are that the required ones are before my component, the
> optional ones are after my component, but that shouldn’t have anything to
> do with.
>
> For completeness, here is more of my .tml file, what you see here are the
> two required date fields, my new component, and then the two optional date
> fields.
>
> Thanks in advance for any help.
> Tony
>
>
>
>
> 
> Since 1982, Starpoint Solutions has been a trusted source of human capital
> and solutions. We are committed to our clients, employees, environment,
> community and social concerns. We foster an inclusive culture based on
> trust, respect, honesty and solid performance. Learn more about Starpoint
> and our social responsibility at http://www.starpoint.com/
> social_responsibility
>
> 
> This email message from Starpoint Solutions LLC is for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information. Any unauthorized review, use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please contact the
> sender by reply email and destroy all copies of the original message.
> Opinions, conclusions and other information in this message that do not
> relate to the official business of Starpoint Solutions shall be understood
> as neither given nor endorsed by it.
>


Unable to get clientId in a component [T5.3.8]

2017-01-09 Thread Tony Nelson
I’m trying to build a simple component that references up to 4 components on my 
page.

I’m using the component like this:





dateRangeFrom, dateRangeTo are both required in the component, and work fine

@Parameter(required = true, defaultPrefix = BindingConstants.COMPONENT)
private Field dateRangeFrom;

@Parameter(required = true, defaultPrefix = BindingConstants.COMPONENT)
private Field dateRangeTo;

relatedRangeFrom and relatedRangeTo are non-null, in after render, and they are 
the right type, but the clientId always returns null

@Parameter(required = false, defaultPrefix = BindingConstants.COMPONENT)
private Field relatedRangeFrom;

@Parameter(required = false, defaultPrefix = BindingConstants.COMPONENT)
private Field relatedRangeTo;


afterRender() does the normal things

@Import(library = "DateRangePreset.js")
void afterRender() {

JSONObject specs = new JSONObject();
specs.put("select", "#" + dateRangePresetSelect.getClientId());
specs.put("dateRangeFrom", "#" + dateRangeFrom.getClientId());
logger.info("ff: " + relatedRangeFrom);

if (relatedRangeFrom != null) {
logger.info("rel: " + relatedRangeFrom.getClientId());
// specs.put("relatedRangeFrom", "#" + 
relatedRangeFrom.getClientId());
specs.put("relatedRangeFrom", "#compareDateRangeFrom");
}

}

In the log I see

[INFO ][DateRangePreset] ff: 
org.apache.tapestry5.corelib.components.DateField@46490fee
[INFO ][DateRangePreset] rel: null


The only thing that’s different between the required DateFields and the 
optional ones, are that the required ones are before my component, the optional 
ones are after my component, but that shouldn’t have anything to do with.

For completeness, here is more of my .tml file, what you see here are the two 
required date fields, my new component, and then the two optional date fields.

Thanks in advance for any help.
Tony





Since 1982, Starpoint Solutions has been a trusted source of human capital and 
solutions. We are committed to our clients, employees, environment, community 
and social concerns. We foster an inclusive culture based on trust, respect, 
honesty and solid performance. Learn more about Starpoint and our social 
responsibility at http://www.starpoint.com/social_responsibility


This email message from Starpoint Solutions LLC is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized review, use, disclosure or distribution is prohibited. If you 
are not the intended recipient, please contact the sender by reply email and 
destroy all copies of the original message. Opinions, conclusions and other 
information in this message that do not relate to the official business of 
Starpoint Solutions shall be understood as neither given nor endorsed by it.