You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tony Nelson <tn...@starpoint.com> on 2015/07/24 17:43:47 UTC

Zone event, new client id

I have a small form in a zone.

When an error occurs in the event handler, I need to execute some javascript, which I’m adding with the ajaxResponseRender.

I can’t figure out how to access the clientId of the component that will be rendered.

If I try to use the Injected component, I get NULL for the client id.

If I try to allocate the client id with javascript support, then the one that is actually used has ‘_0’ appended to it.

I tried changing my event method to void, and adding onSuccess and onFailure.

What is the correct way to get to the client id that will be rendered in an ajax handler?

Thanks in advance,
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.

Re: Zone event, new client id

Posted by Tony Nelson <tn...@starpoint.com>.
Sorry, this is the submit of a zone event.  Here is all of the relevant code.  I did check, afterRender is not called in the chain.

The log line that is generated with this code is:

[INFO] components.EmailForm tinymce.execCommand('mceAddEditor',true,'null');

Thanks again for any help.

@InjectComponent
private Field emailBody;

public void onSendEmail() {
    try {
        messageQueue.sendCommandMessage(commandProducer.createSendJacketEmailMessagesCommand(
                authenticator.getCurrentUser(), to, cc, bcc, subject, body, null));
    }
    catch (Exception ioe) {
        emailForm.recordError("An error occurred processing your request, please try again or contact the help desk");;
    }


}

@Log
Object onFailure() {
    addReInitTinyMCECommand();
    return request.isXHR() ? emailZone.getBody() : null;
}

@Log
Object onSuccess() {
    resetForm();

    if (dialogId != null) {
        addCloseDialogCommand();
    }

    return request.isXHR() ? emailZone.getBody() : null;
}

private void addReInitTinyMCECommand() {
    ajaxResponseRenderer.addCallback(new JavaScriptCallback() {

        @Override
        public void run(JavaScriptSupport javascriptSupport) {

            String cmd = "tinymce.execCommand('mceAddEditor',true,'" + emailBody.getClientId() + "');";
            logger.info(cmd);
            javascriptSupport.addScript(cmd);
        }
    });
}
> On Jul 24, 2015, at 12:01 PM, Thilo Tanner <th...@reprisk.com> wrote:
>
> Hi Tony,
>
> In which render phase are trying to access the client id? It may help if you post parts of your code. Injecting the component to access the client id works for me (for the following common pattern):
>
> @Environmental
> private JavaScriptSupport javaScriptSupport;
>
> @Component
> private Select mySelect;
>
> @AfterRender
> public void afterRender() {
>  javaScriptSupport.require("my-module").invoke("init").with(mySelect.getClientId());
> }
>
>
> This snippet will inject the generated client id in your JS module as a parameter of the init function.
>
> Best,
> Thilo
>
>
>
>
>
> Am 24.07.15 17:43 schrieb "Tony Nelson" unter <tn...@starpoint.com>:
>
>> I have a small form in a zone.
>>
>> When an error occurs in the event handler, I need to execute some javascript, which I’m adding with the ajaxResponseRender.
>>
>> I can’t figure out how to access the clientId of the component that will be rendered.
>>
>> If I try to use the Injected component, I get NULL for the client id.
>>
>> If I try to allocate the client id with javascript support, then the one that is actually used has ‘_0’ appended to it.
>>
>> I tried changing my event method to void, and adding onSuccess and onFailure.
>>
>> What is the correct way to get to the client id that will be rendered in an ajax handler?
>>
>> Thanks in advance,
>> 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.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


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.

Re: Zone event, new client id

Posted by Thilo Tanner <th...@reprisk.com>.
Hi Tony,

In which render phase are trying to access the client id? It may help if you post parts of your code. Injecting the component to access the client id works for me (for the following common pattern):

@Environmental
private JavaScriptSupport javaScriptSupport;

@Component
private Select mySelect;

@AfterRender
public void afterRender() {
  javaScriptSupport.require("my-module").invoke("init").with(mySelect.getClientId());
}


This snippet will inject the generated client id in your JS module as a parameter of the init function.

Best,
Thilo





Am 24.07.15 17:43 schrieb "Tony Nelson" unter <tn...@starpoint.com>:

>I have a small form in a zone.
>
>When an error occurs in the event handler, I need to execute some javascript, which I’m adding with the ajaxResponseRender.
>
>I can’t figure out how to access the clientId of the component that will be rendered.
>
>If I try to use the Injected component, I get NULL for the client id.
>
>If I try to allocate the client id with javascript support, then the one that is actually used has ‘_0’ appended to it.
>
>I tried changing my event method to void, and adding onSuccess and onFailure.
>
>What is the correct way to get to the client id that will be rendered in an ajax handler?
>
>Thanks in advance,
>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.

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