You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joel Trunick <jo...@webifysolutions.com> on 2006/05/01 18:51:07 UTC

Popup on LinkSubmit

I need to show a pop-up when a LinkSubmit is clicked. How do I insert my
JavaScript popup into the call to linksubmit code?

Thanks,
Joel

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


Re: Popup on LinkSubmit

Posted by Omar Valerio <om...@gmail.com>.
Hi,

You may find useful the ConfirmationLinkRenderer from Marius Siegus, just
lookup the list archives to find original posting. I am reposting the code
so you can get an idea of what it looks like.

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.components.ILinkComponent;
import org.apache.tapestry.components.LinkEventType;
import org.apache.tapestry.link.DefaultLinkRenderer;

/**
 * @author Marius Siegas
 * @version $Revision$, $Date$
 *
 */
public class ConfirmationLinkRenderer extends DefaultLinkRenderer {

    /** confirmation message displayed by confirm */
    private String confirmationMessage;

    protected void beforeBodyRender( IMarkupWriter writer, IRequestCycle
cycle, ILinkComponent link) {
        writer.attribute(LinkEventType.CLICK.getAttributeName(),
                "javascript: return
confirm('"+protectConfirmationMessage()+"');");
        super.beforeBodyRender(writer, cycle, link);
    }//beforeBodyRender()

    public String protectConfirmationMessage(){
        return StringEscapeUtils.escapeJavaScript(getConfirmationMessage());
    }//protectConfirmationMessage()

    public String getConfirmationMessage() {
        return confirmationMessage;
    }
    public void setConfirmationMessage(String confirmationMessage) {
        this.confirmationMessage = confirmationMessage;
    }

}//ConfirmationLinkRenderer

I use this class in my links like this:

//excerpted from .page
<page-specification>
...
    <bean name="confirmDelete" class="ConfirmationLinkRenderer">
        <set-property name="confirmationMessage">
            "Confirme que desea borrar el brick seleccionado."
        </set-property>
    </bean>
 ...
    <component id="borrarBrick" type="DirectLink">
       <binding name="renderer" expression="beans.confirmDelete"/>
       <binding name="listener" expression="listeners.borrarBrick"/>
    <binding name="parameters" expression="components.table.tableRow"/>
    </component>
...
</page-specification>

Hope that helps,
--
Omar V.M.

On 5/1/06, Joel Trunick <jo...@webifysolutions.com> wrote:
>
>
> I need to show a pop-up when a LinkSubmit is clicked. How do I insert my
> JavaScript popup into the call to linksubmit code?
>
> Thanks,
> Joel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


--
Thanks,

Henri.

Re: Popup on LinkSubmit

Posted by Henri Dupre <he...@gmail.com>.
Is the popup a tapestry page?
If not then you can just add the javascript code directly, or else you'll
need to write a new component that does that. I did write it already and I
can post the code if you want.

Henri.


On 5/1/06, Joel Trunick <jo...@webifysolutions.com> wrote:
>
>
> I need to show a pop-up when a LinkSubmit is clicked. How do I insert my
> JavaScript popup into the call to linksubmit code?
>
> Thanks,
> Joel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


--
Thanks,

Henri.