Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



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

Answer / Paras Nath Verma

To handle file uploads in Apache Tapestry, you can use the IUploadedFile interface. Here's an example of how to create a simple form for file upload:

1. Define your component with the FileUploadField:
```java
public class UploadForm extends BaseComponent {
private IUploadedFile file;

public void setFile(IUploadedFile file) {
this.file = file;
}

public IUploadedFile getFile() {
return file;
}
}
```
2. Create a form in your page:
```java
public class UploadPage extends BasePage {
private UploadForm uploadForm;

public void setUploadForm(UploadForm uploadForm) {
this.uploadForm = uploadForm;
}

public UploadForm getUploadForm() {
return uploadForm;
}

Object onSubmitFromUploadForm(IRequestCycle cycle, Component component) {
// Handle file upload here
}
}
```
3. In your page's render method, add the form and set its action to call the `onSubmitFromUploadForm()` method:
```java
public void render(MarkupWriter writer) {
super.render(writer);

uploadForm.beginForm("POST").add(uploadForm.fileUploadField("myFile"));
uploadForm.endForm().setAction(createLink("onSubmitFromUploadForm", "component", uploadForm));
}
```
4. Don't forget to add the necessary components and dependencies in your Tapestry configuration.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Apache Tapestry Interview Questions

Can I use the same component multiple times in one template?

1 Answers  


Is tapestry a jsp tag library?

1 Answers  


How do I make a link popup a new window?

1 Answers  


How does tapestry compare to other frameworks?

1 Answers  


How do we write components in apache tapestry?

1 Answers  


Why do we need @script in apache tapestry?

1 Answers  


What is apache tapestry?

1 Answers  


What’s the lifecycle of a form submit?

1 Answers  


I have a form with a submit button. On the form and the submit button are two separate listeners. Which is invoked first?

1 Answers  


How do I integrate a tapestry application with j2ee declarative security/jaas?

1 Answers  


How do I stream a file to the user from tapestry?

1 Answers  


How should do page navigation in apache tapestry?

1 Answers  


Categories