You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jp...@mchsi.com on 2009/06/18 23:33:03 UTC

AjaxSubmitLink

I am trying to use an AjaxSubmitLink to show a panel when a button is clicked. I am receiving the following error when I try to submit the form:

Wicket.Ajax.Call.processComponent: Component with id [[verifyPanelWmc9]] a was not found while trying to perform markup update. Make sure you called component.setOutputMarkupId(true) on the component whose markup you are trying to update.

My code is as follows:

public class InitiateDeclarationPage extends EzdecBaseWebPage {
    @SpringBean
    private IDeclarationService declarationService;

    public InitiateDeclarationPage() {
        final Declaration declaration = new Declaration(EzdecSession.getCurrentUser().getAccount(),
                EzdecSession.getCurrentUser(), "", County.COOK, State.ILLINOIS);
        add(new FeedbackPanel("feedback"));

        final Form form = new Form("initiateDeclarationForm", new CompoundPropertyModel<Declaration>(declaration));
            
        form.add(new Button("submitButton") {
            @Override
            public void onSubmit() {
                Declaration declaration = (Declaration) form.getModelObject();
                declaration.setStatus(Status.OPEN);
                ParcelIdentification pin = declarationService.findParcelIdentification(declaration.getPin());
                if (pin == null) {
                    error("No PIN found for PIN " + getFormattedPIN(declaration.getPin()));
                } else {
                    if (declarationService.initiateDeclaration(declaration)) {
                        EzdecSession.get().info("Declaration " + declaration.getTxNumber() + " created");
                        setResponsePage(new DeclarationPage(declaration, 0, pin));
                    } else {
                        error("Creating declaration with PIN: " + declaration.getPin());
                    }
                }
            }
        });

        final EzdecRequiredTextField pinText = new EzdecRequiredTextField("pin");
        form.add(pinText);
        
        form.add(new DropDownChoice("county", Arrays.asList(County.values()))
                 .setRequired(true)
                 .setEnabled(false));

        final WebMarkupContainer parent = new WebMarkupContainer("verifyPanelWmc");
//        parent.setOutputMarkupId(true);
        parent.setVisible(false);
        form.add(parent);

        AjaxSubmitLink verifyPinLink = new AjaxSubmitLink("verifyPinLink") {
            @Override
            public void onSubmit(AjaxRequestTarget target, Form form) {
                Declaration declaration = (Declaration) form.getModelObject();
                ParcelIdentification pid = declarationService.findParcelIdentification(declaration.getPin());
                if (pid == null) {
                    error("No PIN found for PIN " + declaration.getPin());
                } else {
//                    parent.setOutputMarkupId(true);
                    InitiateDeclarationVerifyPanel decVerifyPanel = new InitiateDeclarationVerifyPanel("verifyPanel", pid);
                    decVerifyPanel.setOutputMarkupId(true);
                    decVerifyPanel.setVisible(true);
                    parent.add(decVerifyPanel);
                    parent.setVisible(true);
                    target.addComponent(decVerifyPanel);
//                    target.addComponent(parent);
                }
            }
        };

        form.add(verifyPinLink);

        add(form);
    }

}

Anyone know how I can get around this?

Re: AjaxSubmitLink

Posted by sander v F <sa...@gmail.com>.
Like the error says: "Make sure you called component.setOutputMarkupId(true)
on the component whose markup you are trying to update."
That would be the component with id: 'verifyPanelWmc'.

Your code:
        final WebMarkupContainer parent = new
WebMarkupContainer("verifyPanelWmc");
//        parent.setOutputMarkupId(true);
        parent.setVisible(false);
        form.add(parent);

I think you tried that already, but because the component is not visible,
the component won't be rendered and written to the response. So there
wouldn't be any component to update with ajax. That's why there's the error
"Component with id [[verifyPanelWmc9]] a was not found while trying to
perform markup update"

You should try "setOutputMarkupPlaceholderTag(true)". This will create a
placeholder so the component can be updated with ajax.





2009/6/18 <jp...@mchsi.com>

>  I am trying to use an AjaxSubmitLink to show a panel when a button is
> clicked. I am receiving the following error when I try to submit the form:
>
> Wicket.Ajax.Call.processComponent: Component with id [[verifyPanelWmc9]] a
> was not found while trying to perform markup update. Make sure you called
> component.setOutputMarkupId(true) on the component whose markup you are
> trying to update.
>
> My code is as follows:
>
> public class InitiateDeclarationPage extends EzdecBaseWebPage {
>     @SpringBean
>     private IDeclarationService declarationService;
>
>     public InitiateDeclarationPage() {
>         final Declaration declaration = new
> Declaration(EzdecSession.getCurrentUser().getAccount(),
>                 EzdecSession.getCurrentUser(), "", County.COOK,
> State.ILLINOIS);
>         add(new FeedbackPanel("feedback"));
>
>         final Form form = new Form("initiateDeclarationForm", new
> CompoundPropertyModel<Declaration>(declaration));
>
>         form.add(new Button("submitButton") {
>             @Override
>             public void onSubmit() {
>                 Declaration declaration = (Declaration)
> form.getModelObject();
>                 declaration.setStatus(Status.OPEN);
>                 ParcelIdentification pin =
> declarationService.findParcelIdentification(declaration.getPin());
>                 if (pin == null) {
>                     error("No PIN found for PIN " +
> getFormattedPIN(declaration.getPin()));
>                 } else {
>                     if
> (declarationService.initiateDeclaration(declaration)) {
>                         EzdecSession.get().info("Declaration " +
> declaration.getTxNumber() + " created");
>                         setResponsePage(new DeclarationPage(declaration, 0,
> pin));
>                     } else {
>                         error("Creating declaration with PIN: " +
> declaration.getPin());
>                     }
>                 }
>             }
>         });
>
>         final EzdecRequiredTextField pinText = new
> EzdecRequiredTextField("pin");
>         form.add(pinText);
>
>         form.add(new DropDownChoice("county",
> Arrays.asList(County.values()))
>                  .setRequired(true)
>                  .setEnabled(false));
>
>         final WebMarkupContainer parent = new
> WebMarkupContainer("verifyPanelWmc");
> //        parent.setOutputMarkupId(true);
>         parent.setVisible(false);
>         form.add(parent);
>
>         AjaxSubmitLink verifyPinLink = new AjaxSubmitLink("verifyPinLink")
> {
>             @Override
>             public void onSubmit(AjaxRequestTarget target, Form form) {
>                 Declaration declaration = (Declaration)
> form.getModelObject();
>                 ParcelIdentification pid =
> declarationService.findParcelIdentification(declaration.getPin());
>                 if (pid == null) {
>                     error("No PIN found for PIN " + declaration.getPin());
>                 } else {
> //                    parent.setOutputMarkupId(true);
>                     InitiateDeclarationVerifyPanel decVerifyPanel = new
> InitiateDeclarationVerifyPanel("verifyPanel", pid);
>                     decVerifyPanel.setOutputMarkupId(true);
>                     decVerifyPanel.setVisible(true);
>                     parent.add(decVerifyPanel);
>                     parent.setVisible(true);
>                     target.addComponent(decVerifyPanel);
> //                    target.addComponent(parent);
>                 }
>             }
>         };
>
>         form.add(verifyPinLink);
>
>         add(form);
>     }
>
> }
>
> Anyone know how I can get around this?
>