Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Apache Tapestry Interview Questions and Answers

Ques 6. How to alter the URL to point to the correct page?

You would need to throw a RedirectException with the new URL; this sends an HTTP redirect to the client.

Is it helpful? Add Comment View Comments
 

Ques 7. How should do page navigation in apache tapestry?

Usage page properties:

Page1.page
<page-specification class="Welcome.Action">
        <property name="success" value="Home" />
        <property name="error" value="Error" />
</page-specification>

Page2.page
<page-specification class="Welcome.Action">
        <property name="success" value="Home2" />
        <property name="error" value="Error2" />
</page-specification>

Welcome.Action.java
public void submitListener(IRequestCycle cycle)
{
    if (success)
        cycle.activate(getSpecification().getProperty("success"));
    if (error)
        cycle.activate(getSpecification().getProperty("error"));
}

So on success, it will be redirected to Home2 and on error it will be redirected to Error2 page.

Is it helpful? Add Comment View Comments
 

Ques 8. How do I make a link popup a new window?

Use the contrib:PopupLink component.

Is it helpful? Add Comment View Comments
 

Ques 9. How to get a file from client input to server end in apache tapestry?

Make a method like the following a a listener, such as from a DirectLink or whatever.
(The Document is just a class that holds the file information you want to send to the user.)

public void downloadAction(IRequestCycle cycle)
{
    try
    {
        HttpServletResponse response =
        cycle.getRequestContext().getResponse();

        byte[] data = new byte[1024];
        FileInputStream in = document.getFileInputstream();

        response.setHeader("Content-disposition",
          "inline; filename=" +
           document.getFileName());
        response.setContentType(document.getMimeType());
        response.setContentLength(new Long(document.getSize()).intValue());
        ServletOutputStream out = response.getOutputStream();

        while (in.read(data) > -1)
        {
            out.write(data);
        }
        in.close();
        response.flushBuffer();
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2022 WithoutBook