Last active
August 29, 2015 14:06
-
-
Save uklance/bdad1e26cc99b9eccbaa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FileBean { | |
private UploadedFile file; | |
public void setUploadedFile(UploadedFile file) { | |
this.file = file; | |
} | |
public UploadedFile getUploadedFile() { | |
return file; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Page { | |
@Property | |
private List<FileBean> fileBeans; | |
@Property | |
private FileBean fileBean; | |
public ValueEncoder<FileBean> getFileBeanEncoder() { | |
return new ValueEncoder<FileBean> { | |
public String toClient(V value) { | |
return "placeholder"; | |
} | |
// tapestry will call this for each placeholder on the client | |
// it will call FileBean.setUploadedFile() with the UploadedFile instance | |
public FileBean toValue(String client) { | |
if (fileBeans == null) { | |
fileBeans = new ArrayList<FileBean>(); | |
} | |
FileBean value = new FileBean(); | |
fileBeans.add(value); | |
return value; | |
} | |
}; | |
} | |
public FileBean onAddRow() { | |
// initialize the fileBean property so that tapestry can render another row | |
fileBean = new FileBean(); | |
// return the fileBean instance so that tapestry can store a placeholder on the client | |
return fileBean; | |
} | |
public void onSuccess() { | |
doStuff(fileBeans); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<t:ajaxformloop source="fileBeans" value="fileBean" encoder="fileBeanEncoder"> | |
<t:upload t:value="fileBean.uploadedFile" /> | |
</t:ajaxformloop> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment