Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

alix jermyn

Greenhorn
+ Follow
since May 05, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by alix jermyn


Hi guys, a small but annoying problem

I am using a simple requiredMessage attribute to display the validation error message on the listbox below when a data is not selected

<h:selectOneListbox id="selectDateId" value="#{dateBean.selectedDate}" size="12" required="true" requiredMessage="#{msg.date_required}" >


The error message is correctly showing up in the messages element below, except that it is duplicated.

<h:messages showDetail="true" fatalClass="messageFatal" errorClass="messageError" warnClass="messageWarn" infoClass="messageInfo" />

If I set showDetail="false", there is no duplication, so I am presuming that the FacesMessage that is being created behind the scenes is filling both the summary and detail fields with the same value. Does anyone know of any workaround to stop this duplication - I would prefer to leave the showDetail="true" to pick up other messages that do have genuine detail fields

/alix

12 years ago
JSF

Hi

Users in our app can currently download a simple text file by clicking the appropriate button on a JSF page, the code snippet for which is shown below.
After their browser pops up the download window and the download is successful, their browser shows the same page they had before they clicked on the button.

Is it possible to send a multipart response back to the browser - containing the download, and the html for the next page they should see after the download?


--------------------- cleaned snippet for simple download, which works fine as it is -------------------------------
String exportedReport = generateReport();
bytes[] exportedBytes = exportedReport.getBytes();
String filename = "yourReport.txt";
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
response.setContentType("text/plain");
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
response.setContentLength(exportedBytes.length);
try {
response.getOutputStream().write(exportedBytes);
response.getOutputStream().flush();
//response.getOutputStream().close();
context.responseComplete();
}
12 years ago
JSF