alerts

my page uploads a file and when the file is successfully loaded I am supossed to display a message.. So if was able to do that by having a boolean in one class and I pull its value and use it for the rendered attribute of an output text..

It works fine since the boolean has a setter and getter.. only problem is that I can't seem to reset the rendered attribute back to false.. so that when the user searches something else the Success Message won't have to display..

any suggestions, like perhaps an alert box in JSF?

here are parts of my code..

JSF><h:commandButton id="e2Csv" value="Export to CSV" action="#{statisticsController.createString}" disabled="#{empty statisticsController.status}"/>

<h:outputText id="msg" rendered="#{statisticsController.upload}" value="File Successfully Exported!"/>

JAVA->

privateboolean Upload=false;

publicboolean isUpload(){

return Upload;

}

publicvoid setUpload(boolean upload){

Upload = upload;

}

String str ="";

StringBuilder sb =new StringBuilder();

String attVal="";

String allSer="";

String unqSer="";

sb.append("Summary from "+dateFrom+" to "+dateTo+"\n");

sb.append("Total,Number of Searches");

if(total.getBrandTotal()!=0){

str ="By Brand";

sb.append("\n\n"+str+","+total.getBrandTotal()+"\n");

sb.append("Brand,All Searches,Unique Searches\n");

for (StatisticsResultBreakdown el : breakdownForBrand){

attVal = el.getAttributeValue();

if(attVal.contains(",")){

attVal ="\""+attVal+"\"";

}

log.debug(attVal);

allSer = el.getAllSearches();

unqSer = el.getUniqueSearches();

sb.append(attVal+","+allSer+","+unqSer+"\n");

}

}

setCsvText(sb.toString());

log.debug(getCsvText());

setUpload(fileControl.uploadCsv(getCsvText()));

[3271 byte] By [Arch_Bytesa] at [2007-11-27 6:09:22]
# 1

Instead of that u can create a request scope bean which has a string variable saying UserMessage. so now start using this request scope bean in your pagecode, and bind that UserMessage string to ur <h:outputText> . When ever ur method in pagecode returns successful with out any errors/exceptions then u can set that request scope bean UserMessage variable to ur own message, and the string gets reset for every new request.

and this would act as a generalized process in your application coz its a request scope bean string and u can use it any where u what in your application.

hope this solves ur issue

KiranDa at 2007-7-12 17:13:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
ok..so now I have to learn how to create that request scope bean.. any hints or snippets? does it have to be in the faces-config.xml file?Thanks for the tip!
Arch_Bytesa at 2007-7-12 17:13:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...