Re: using html:option tag
The html:select tag has an attribute value. http://struts.apache.org/userGuide/struts-html.html#select The value to compare with for marking an option selected. [RT Expr] HTH, Glenn [EMAIL PROTECTED] 27/09/2005 12:08 PM Please respond to Struts Users Mailing List user@struts.apache.org To user@struts.apache.org cc Subject using html:option tag Hi All, I am using the html option tag embedded within the html select tag to select a value from a drop down list as follows: html:select property=title html:option value=MrMr/html:option html:option value=MrsMrs/html:option /html:select This works fine and I can save the correct value to the database. The question I have is how do I display the same option tag when updating the user and the details are returned from a database. So in plain English after the user has saved the client to the db he then wants to update the record. A search is done but how do I display on the JSP page the selected option with the option of seleting something else from the drop down list. Thanks in advance
Re: Forwarding to the previous page
You can always get from where the request is coming from by getting the Referer from the Request. String referer = request.getHeader(REFERER); I'm not sure that this is want you want. You must beware that the referrer can be blank when typing in the URL in the browser, plus the consequences of the ActionForm.validate() and errors. HTH, Glenn Tremal Naik [EMAIL PROTECTED] 07/09/2005 12:22 PM Please respond to Struts Users Mailing List user@struts.apache.org To Struts Users Mailing List user@struts.apache.org cc Subject Re: Forwarding to the previous page 2005/9/7, Duane Rosengartner [EMAIL PROTECTED]: This works very well for me. a class=button href=javascript:history.back()Back/a aehm,probabily I didn't explain well my problem: I don't have to get back to the previous page from the actual. Look at this code: public class DisplayAboutAction extends Action { public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { // do stuff. ActionForward af = new ActionForward(); af.setPath(previousPagePath); return af; } } I need to get a value for 'previousPagePath'. I'm trying something like : bean:page id=reqq property=request / html:link action=next.do paramId=old_page paramName=reqq paramProperty=servletPath but I'm using Tiles, so what I have as 'old_page' parameter is not the action 'previous.do' but '/jsplayout.jsp' instead thanks, TREMALNAIK - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Select Options Question
You can also build a javascript array of the descriptions. When the user selects the option from the list, execute a javascript function that will do a lookup for the description in the array and set a hidden form field with the description found in the array. It may happen that the character you use to delimit the key and value will end up in the value and then the fun starts ! HTH, Glenn [EMAIL PROTECTED] 01/09/2005 12:07 PM Please respond to Struts Users Mailing List user@struts.apache.org To Struts Users Mailing List user@struts.apache.org cc Struts Users Mailing List user@struts.apache.org Subject Re: Select Options Question On the result page I only need the Label for the selected option. Not the entire list. The problem is that when you submit the form, you only submit the value in the form object and loose the label. I need to pass the label as well so that I do not have to requery for it. The way that i have it currently is that the value contains a comma delemited string containing both the label and key (overkill on the bandwidth I know). In my action class, I do a string.split on the comma and pass the first value to my DAO processor and the Second value I put in my form for display. It is the only way I could think of without iterating through the options or storing the initial results which populate the option list. Frank W. Zammetti [EMAIL PROTECTED] Frank W. Zammetti [EMAIL PROTECTED] 09/01/2005 11:28 AM Please respond to Struts Users Mailing List user@struts.apache.org To Struts Users Mailing List user@struts.apache.org cc Subject Re: Select Options Question I'm not sure I understand... do you just need to have the group name when you display the detail for the selected item, or do you need the entire select list (to avoid getting it from the datavase each time?) If you just need the grou pname, could you simply put the group name in session? May or may not work depending on the flow of your app, but it would be a nice, simple solution if it'll work... just remember to clear it out at an appropriate time. The other option that comes to mind immediately is indeed to use Javascript... seems like all you'd need is a form with two hidden fields, groupName and value... onChange of the select, populate those two fields and submit() the form. You'd then have both pieces of information to render your detail page. Or maybe I don't understand the problem? Frank [EMAIL PROTECTED] wrote: I am sure there is a slick way to do this, but it escapes me at the moment. I have a Select Box that I am populating with the html:options tag The result is: select name=cmbGroup id=groupList option value=jk12341Group 1/option option value=34t1fv1Group 2/option option value=32fq21Group 3/option ... /select I need the value for DAO actions performed from the search which will return a detail bean for display on an output JSP. On the output JSP I need to Display the Group Name that I selected from the input. My Form holds the group id and a field for the group name. The options that I can see are: 1. Requery the Database for the output page to retrieve the name given I have the key. This would work, but seems like a lot of overhead to go to the database each time. 2. Create a delimited value (ie option value=jk12341, Group 1Group 1/option) and use the String Split to get the value and label. (I am leaning toward this) 3. use javascript to update the field each time the select changes. The problem with this is that the select box can be very large based on the users selections on previous entries. 4. Store the Value Label list in the session (Don't like this at all because the volume of users that will use this application). Any other suggestions? -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: logout problem
I have used the meta http-equiv=Refresh content=300; URL=../action/Logout.do/ tag in an application that is very information sensitive. The idea is that the sensitive information does not stay displayed unused for nothing. This was a user requirement. BTW, you don't need an iframe. Also, you can never catch all instances where a logout will occur, such as logging off the machine... or just pressing the power button. - Glenn Leon Rosenberg [EMAIL PROTECTED] 31/08/2005 08:17 AM Please respond to Struts Users Mailing List user@struts.apache.org To Struts Users Mailing List user@struts.apache.org cc Subject Re: logout problem On Wed, 2005-08-31 at 12:46 +0100, Adam Hardy wrote: Emmanouil Batsis on 31/08/05 12:37, wrote: SÅ‚awek Tuleja wrote: question: but how to evoke Logoff action when user closes browser? In general you dont :-) You just wait for the session to expire using a session event listener. However, if the client supports javascript, you can catch the onclose event and perhaps submit an XMLHTTPRequest to the server (if the object is supported), but you cannot actually rely on this. If you're mad keen on the idea and wish to avoid javascript, put an invisible iframe in the page with a meta http-equiv=Refresh content=15; URL=../action/redirect.html/ in the header, so that the client's browser continually polls the server, and set a listener to do something when it stops. I would never do that myself though ;) why not? regards Leon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: messages help
Did you read this ? http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html Especially the section 4.2 Using a Custom Key. HTH, Glenn draegoon Z [EMAIL PROTECTED] 22/08/2005 02:19 PM Please respond to Struts Users Mailing List user@struts.apache.org To struts-user@jakarta.apache.org cc Subject messages help Sorry, but I've been reading archives all morning. Using Struts 1.2.7 Setting up a system to catch all errors/messages on a page. Getting the errors from my ActionForm: ActionErrors errors = new ActionErrors(); errors.add(system_name,new ActionError(errors.required,ar.getMessage(com.draegoonZ.social.label.system_name))); return(errors); Getting the ???bad_key??? from my ActionForm: ActionMessages errors = new ActionMessages(); errors.add(system_name,new ActionMessage(ar.getMessage(com.draegoonZ.social.password.lookup.no_user_name))); saveMessages(request,errors); return(mapping.getInputForward()); Results in: ???en_US.That username doesn't exist in our system. Please try again.??? Now I don't know what key it is telling me is missing, when it is displaying the value from my messages resource. I thought the problem was with using the property (system_name) instead of ActionMessages.GLOBAL_MESSAGE, but that gave the same results. Also, I want to use the property name, so I can display next to the html: input tag. A related question I have is: I read somewhere (this morning) that once html:message is read/accessed that it is removed/deleted. Is this true? How then could one list all the errors/messages at the top of a page, and then check for them to display next to the html: input tag? My jsp reads: %-- check for errors --% logic:messagesPresent html:messages id=message_id header=errors.header footer=errors.footer lic:out value=${message_id} //li /html:messages /logic:messagesPresent %-- If not errors present... --% logic:messagesNotPresent %-- check for messages (Globals.MESSAGE_KEY) --% logic:messagesPresent message=true html:messages id=message_id message=true header=errors.header footer=errors.footer lic:out value=${message_id} //li /html:messages /logic:messagesPresent /logic:messagesNotPresent Thanx in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
html-el:messages - bis
Greetings, I have sent this post more almost 2 days ago without one response. I hope it was simply lost with other posts but still worthy of attention. Here is the original post: I am unable to find a solution... even after searching... and waiting for the espresso to kick in. I have messages and would like to determine the number of messages in the bean. If there is more than one message format the output as a list or else just display the message. Unable to come up with something. This is what I am currently using: logic:messagesPresent message=true tr td colspan=5 class=informationalMessage html-el:messages id=message message=true bean: write name=message filter=false/br /html-el:messages /td td/td /tr tr td colspan=6 height=5/td /tr /logic:messagesPresent Any ideas would be greatly appreciated ! - Glenn
html:messages
Greetings, I am unable to find a solution... even after searching... and waiting for the espresso to kick in. I have messages and would like to determine the number of messages in the bean. If there is more than one message format the output as a list or else just display the message. Unable to come up with something. This is what I am currently using: logic:messagesPresent message=true tr td colspan=5 class=informationalMessage html-el:messages id=message message=true bean: write name=message filter=false/br /html-el:messages /td td/td /tr tr td colspan=6 height=5/td /tr /logic:messagesPresent Any ideas would be greatly appreciated ! - Glenn
Re: Token element wrapped with a div tag
This is the JSP code snippet: html-el:form action=/personal/BeneficiarySubmit method=post focus= ${HTMLFocusElement.elementName} html-el:hidden property=bid value= ${beneficiaryForm.beneficiary.beneficiaryId}/ html-el:hidden property=beneficiaryAdd/ Here is the HTML source: form name=beneficiaryForm method=post action=/hronline/secure/personal/BeneficiarySubmit.dodivinput type=hidden name=org.apache.struts.taglib.html.TOKEN value=0e4c64c9eeefb8cf6be7f6f09cb183df/div input type=hidden name=bid value=D00 input type=hidden name=beneficiaryAdd value=true Here is code in my Action class: // set the synchronization token String token = generateToken(request); httpSession.setAttribute(Globals.TRANSACTION_TOKEN_KEY, token); - Glenn Laurie Harper [EMAIL PROTECTED] Sent by: news [EMAIL PROTECTED] 14/07/2005 06:29 PM Please respond to Struts Users Mailing List user@struts.apache.org To user@struts.apache.org cc Subject Re: Token element wrapped with a div tag [EMAIL PROTECTED] wrote: Just curious as to why in the JSP the token is wrapped in a div tag? divinput type=hidden name=org.apache.struts.taglib.html.TOKEN value=383952ea7a0093448e02f3f0d635865b/div I'm using v1.2.7. What does your JSP look like? L. -- Laurie, Open Source advocate, Java geek and novice blogger: http://www.holoweb.net/~laurie/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Token element wrapped with a div tag
Thanks Niall. It did not occur to me to check the ASF Bugzilla for Struts [I will remember for the next time]. I'm not familiar with the Status... since it is not yet closed.. this means that the bug is not yet fixed in version 1.2.7 ? - Glenn Niall Pemberton [EMAIL PROTECTED] 18/07/2005 08:38 AM Please respond to Struts Users Mailing List user@struts.apache.org To Struts Users Mailing List user@struts.apache.org cc Subject Re: Token element wrapped with a div tag http://issues.apache.org/bugzilla/show_bug.cgi?id=32016 Niall - Original Message - From: [EMAIL PROTECTED] Sent: Thursday, July 14, 2005 4:11 PM Hi, Just curious as to why in the JSP the token is wrapped in a div tag? divinput type=hidden name=org.apache.struts.taglib.html.TOKEN value=383952ea7a0093448e02f3f0d635865b/div I'm using v1.2.7. Regards, Glenn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Token element wrapped with a div tag
Thanks Niall for your time and patience. - Glenn Niall Pemberton [EMAIL PROTECTED] 18/07/2005 10:33 AM Please respond to Struts Users Mailing List user@struts.apache.org To Struts Users Mailing List user@struts.apache.org cc Subject Re: Token element wrapped with a div tag Sorry, my reply wasn't very verbose. That bug is fixed in Version 1.2.7 - which is why you're seeing the div elements. Generally we're not very good at actually closing bugs - once they're marked as RESOLVED they don't generally get any more attention. So if you see RESOLVED FIXED then it means its been done. Finding out whether a fix has made it into a released version or is just currently in the current svn repository is another matter. The release notes usually contain details of fixed bugs so thats probably the easiest way, if you know the bug number. http://struts.apache.org/userGuide/release-notes.html Niall - Original Message - From: [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Monday, July 18, 2005 1:55 PM Subject: Re: Token element wrapped with a div tag Thanks Niall. It did not occur to me to check the ASF Bugzilla for Struts [I will remember for the next time]. I'm not familiar with the Status... since it is not yet closed.. this means that the bug is not yet fixed in version 1.2.7 ? - Glenn Niall Pemberton [EMAIL PROTECTED] 18/07/2005 08:38 AM http://issues.apache.org/bugzilla/show_bug.cgi?id=32016 Niall - Original Message - From: [EMAIL PROTECTED] Sent: Thursday, July 14, 2005 4:11 PM Hi, Just curious as to why in the JSP the token is wrapped in a div tag? divinput type=hidden name=org.apache.struts.taglib.html.TOKEN value=383952ea7a0093448e02f3f0d635865b/div I'm using v1.2.7. Regards, Glenn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Token element wrapped with a div tag
Hi, Just curious as to why in the JSP the token is wrapped in a div tag? divinput type=hidden name=org.apache.struts.taglib.html.TOKEN value=383952ea7a0093448e02f3f0d635865b/div I'm using v1.2.7. Regards, Glenn
Re: reponse commited
Quickly glancing at your code I believe you need to return null such as ostr.close(); return null; HTH, Glenn Karthika L V somayajula [EMAIL PROTECTED] 14/06/2005 10:35 AM Please respond to Struts Users Mailing List user@struts.apache.org To user@struts.apache.org cc Subject reponse commited I hope am into the right group I have a problem with downloading files using struts. I am using J2SDK 1.4.2_06 Struts 1.2.4 Jboss 4.0.1RC2 My download Action is : public ActionForward executeAction( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws BusinessDelegateException,IOException { ReportGenerateForm rform = (ReportGenerateForm) form ; ActionForward forward = mapping.findForward(Constant.DOWNLOAD_REPORT); ReportGenerateDelegate reportGenerateDelegate = new ReportGenerateDelegate(); int empId = getIntranetUser( request ).getEmployeeID(); String reportId = request.getParameter(rid); String companyId = String.valueOf(getIntranetUser(request).getCompanyId()); String companyName = getIntranetUser(request).getCompanyName(); String projectId = Constant.STRING_ZERO; String projectName = Constant.BLANK; String fn = reportGenerateDelegate.getFileName(reportId); //prepend employee Id to file Name StringBuffer file = new StringBuffer(String.valueOf(empId)); file.append(Constant.FILENAME_SEPERATOR_LITERAL).append(fn); String fileName = new String(file); // scrub the company name ArrayList arr = new ArrayList(); arr.add(companyName); arr = (ArrayList)rform.validateData( arr ) ; String scrubbedCompanyName = (String)arr.get(0); IntranetLogger.logInfo(Scrubbed Comapny Name is +scrubbedCompanyName); arr = null; if( fileName != null ) { File fname = new File(fileName); FileUpload fileUpload = new FileUpload(); String default_folder = Constant.REPORTS_FOLDER; String relativePath = FileUpload.getPathName (companyId,scrubbedCompanyName,projectId,projectName,default_folder); // append relative path to the Document Root defined in FileUpload.properties file String downloadPath = FileUpload.getPath(Constant.BLANK) + relativePath; IntranetLogger.logInfo(In DownloadReportAction FULL PATH of the file. + downloadPath); FileInputStream istr = null ; OutputStream ostr = null; try { IntranetLogger.logInfo(TOTAL DOWNLOAD PATH IS: +(downloadPath + fname)); istr = new FileInputStream( downloadPath + fname); IntranetLogger.logInfo(File available? + istr.available()); IntranetLogger.logInfo(File name +fileName); if ( istr.available() == 0 ) { IntranetLogger.logInfo(File Not available + fileName); addErrors(error.document.empty, fileName,request); } else { // set content type of the response object to Application/octet-stream. By setting this // we can download any type of file like txt, pdf, doc, xls etc response.setContentType(APPLICATION/OCTET-STREAM); response.setHeader(Content-Disposition, attachment;filename=\ + fname.getName() +\;); IntranetLogger.logInfo(Reponse content type set); // the following line is required to send a pop-up open-save-cancel file dialog box ostr = response.getOutputStream(); int bytesRead = 0; byte[] buffer = new byte[8192]; while( (bytesRead = istr.read(buffer, 0, 8192)) != -1) { ostr.write(buffer, 0, bytesRead); } //ostr.flush(); istr.close(); ostr.close(); addMessages(download.success, fileName, request); } }//try catch(Exception ex) { IntranetLogger.logInfo(Error in flushing out the Streams: +ex.toString()); // if file already exists, then gives the proper messeage. addErrors(error.document.empty, fileName,request); //forward = mapping.findForward( Constant.GENERATE_REPORT) ; forward = mapping.findForward(Constant.DOWNLOAD_REPORT); } finally { try { istr.close(); ostr.close(); } catch(Exception ex) { IntranetLogger.logInfo(Major Error Releasing Streams: +ex.toString()); addErrors(error.document.empty, fileName,request); } } try { response.flushBuffer(); } catch(Exception ex) { IntranetLogger.logInfo(Error flushing the Response: +ex.toString()); addErrors(error.document.empty, fileName, request); } } return forward; } My jsp includes meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 I get the list of file name with links in my JSP, one of which I click i should get a open, save file dialog box Now, when i click on the the filename on link I get the exception StandardWrapperValve[action]: cannot forward,reponse already commited Please reply if you find mistakes or errors in my action Thank you advance Karthika - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confused
Pierre, Struts is no longer a sub-project of Jakarta but is now on its own. Struts is alive and kicking: http://struts.apache.org/ You can look at section 6 [this might help]: http://struts.apache.org/userGuide/index.html As for JBoss... the last time I used it (can't exactly remember when)... JBoss has a version that is already bundled with Tomcat. As for the Mac, I cannot really help. HTH, Glenn Pierre Thibault [EMAIL PROTECTED] 13/06/2005 12:01 AM Please respond to Struts Users Mailing List user@struts.apache.org To user@struts.apache.org cc Subject Confused Hello, I am new to Struts and I am a bit confused. I would like some light. I have just installed Tomcat 5 for Java WSDP. Do I need this version to make Struts development or can I use the regular 5.5 version too? I have installed both. I also saw that Struts is listed in the Ex-Jakarta section of the Jakarta web site. Is this mean that Struts is now replaced by Tapestry? Also, I would like to know how can I have access to J2EE? I am on Mac OS 10.4 and as I know I need JBoss to have access to J2EE. I have installed JBoss on my machine too. But I don't understand how can I use Tomcat, JBoss and Struts altogether. Can you help me? Regards. - Pierre