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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category