The images will be uploaded on context - layout - images folder.

View Template

${ImagePath} 


View Page Class


public Asset getImagePath(){
        
        return
this.assetSource.getAsset(this.resource.getBaseResource(),"context:layout/images/"
+ picfilename, null);
    }


Upload Template


<form t:type="form">
<t:errors/>
<input t:type="upload" t:id="file" validate="required" />
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>


Upload Page Class


@Property
private UploadedFile file;
    
@Persist(PersistenceConstants.FLASH)
@Property
private String uploadmessage;

@Inject
private ApplicationGlobals globals;

public String getUploadError(){
        
        return uploadmessage;
}
    
public Object onUploadException(FileUploadException ex)
{
        uploadmessage = "Upload exception: " + ex.getMessage() + " You can
only upload file less than or equal to 500kb.";

        return this;
}

public void onSuccess() {

// Set Path
String path = globals.getServletContext().getRealPath("/layout/images") +
"/";

File copied;
        
// Get File
copied = new File(path + file.getFileName());

// File Saved
file.write(copied);

}


--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/T5-Upload-File-View-Guide-Example-tp4483459p4483459.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to