Re: Struts 1 Javascript Question
2008/3/27, bhaarat Sharma [EMAIL PROTECTED]: Hello I am using struts 1 to show a link to the user like this html:link page=/editProjectMonitor.do paramId=report_id paramName=report paramProperty=reportId target=_blank Edit/html:link However I want this link to open up from Javascript instead! Oh, the lazyness... http://struts.apache.org/1.x/struts-taglib/tlddoc/html/link.html The html:link has a onclick attribute. Imagine what's this for? Antonio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1 Javascript Question
bhaarat Sharma wrote: Hello I am using struts 1 to show a link to the user like this html:link page=/editProjectMonitor.do paramId=report_id paramName=report paramProperty=reportId target=_blank Edit/html:link However I want this link to open up from Javascript instead! For javascript I have a code like the following function openPopup() { windowReference = window.open('/cmrs/editProjectMonitor.do?report_id=%=WHAT TO PUT HERE? SO I CAN GETT report_id value%','windowName'); if (!windowReference.opener) windowReference.opener = self; } what can i pass so that report_id value will come. I know in struts2 I could have used the s:property tag...is there something similar in struts1? Antonio is right, the onclick attribute is probably the easiest way to do this, but to answer the question: you can use an EL expression if you have them available, as in: ...window.open('...?report_id=${report.reportId}' or, if you don't have JSTL available in your container, you can use the bean:write tag: ...window.open('...?report_id=bean:write name=report property=reportId/' L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts and javascript
html:select name=Form1 property=typeselected onchange='showPopup(html:rewrite action=/PrepareSchedule.do/);' this is wrong. because as far as I know, a struts tag's atrribute sholud not be filled with mixed stuff by jsp codes and plain text. if you write this way: html:select name=Form1 property=typeselected onchange=html:rewrite action=/PrepareSchedule.do/ I guess the error won't occur.
RE: struts and javascript
The JS file is retrieved by the browser after the page loads and is not processed on the server, so the html:rewrite tag will not be interpreted. Either leave the script in the JSP as you mentioned, or include it in the JSP via server-side JSP include, or configure you web/app server to run .js files through the JSP processor. Frank -Original Message- From: fea jabi [EMAIL PROTECTED] To: user@struts.apache.org Sent: 4/13/06 9:14 AM Subject: struts and javascript In a JS file I created a function as below. function showPopup(htmlRewrite) { var w = 480, h = 340; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } var popW = 200, popH = 100; var leftPos = (w-popW)/2, topPos = (h-popH)/2; window.open( 'htmlRewrite', , resizable, toolbar=yes, statusbar=yes, menubar=yes, status=yes, location=yes, scrollbars=yes, 'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); } But getting error at the select statement below. how to call the above function?? html:select name=Form1 property=typeselected onchange='showPopup(html:rewrite action=/PrepareSchedule.do/);' htmlptions collection=typeList property=value labelProperty=label/ /html:select * Was working fine when I had the js function in the jsp itself. i.e it was working fine with below code function showPopup() { var w = 480, h = 340; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } var popW = 200, popH = 100; var leftPos = (w-popW)/2, topPos = (h-popH)/2; window.open('html:rewrite action=/PrepareSchedule.do/', , resizable, toolbar=yes, statusbar=yes, menubar=yes, status=yes, location=yes, scrollbars=yes, 'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); } /script html:select name=Form1 property=typeselected onchange='showPopup();' htmloptions collection=typeList property=value labelProperty=label/ /html:select But now trying to have a common function in the js file and pass an argument for the url it has to go to. what's is the right way of doing this? Thanks. _ Is your PC infected? Get a FREE online computer virus scan from McAfee Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts and javascript
Or generate the target location in JSP like this: script language=javascript var mytarget = html:rewrite action=/PrepareSchedule.do/ /script Then look up for target in your main Javascript function. I guess it would be easier to attach target to some well-know object like window, for example: window.mytarget = html:rewrite action=/PrepareSchedule.do/ I am not a Javascript pro, but you get the idea. On 4/13/06, Frank W. Zammetti [EMAIL PROTECTED] wrote: The JS file is retrieved by the browser after the page loads and is not processed on the server, so the html:rewrite tag will not be interpreted. Either leave the script in the JSP as you mentioned, or include it in the JSP via server-side JSP include, or configure you web/app server to run .js files through the JSP processor. Frank -Original Message- From: fea jabi [EMAIL PROTECTED] To: user@struts.apache.org Sent: 4/13/06 9:14 AM Subject: struts and javascript In a JS file I created a function as below. function showPopup(htmlRewrite) { var w = 480, h = 340; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } var popW = 200, popH = 100; var leftPos = (w-popW)/2, topPos = (h-popH)/2; window.open( 'htmlRewrite', , resizable, toolbar=yes, statusbar=yes, menubar=yes, status=yes, location=yes, scrollbars=yes, 'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); } But getting error at the select statement below. how to call the above function?? html:select name=Form1 property=typeselected onchange='showPopup(html:rewrite action=/PrepareSchedule.do/);' htmlptions collection=typeList property=value labelProperty=label/ /html:select * Was working fine when I had the js function in the jsp itself. i.e it was working fine with below code function showPopup() { var w = 480, h = 340; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } var popW = 200, popH = 100; var leftPos = (w-popW)/2, topPos = (h-popH)/2; window.open('html:rewrite action=/PrepareSchedule.do/', , resizable, toolbar=yes, statusbar=yes, menubar=yes, status=yes, location=yes, scrollbars=yes, 'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); } /script html:select name=Form1 property=typeselected onchange='showPopup();' htmloptions collection=typeList property=value labelProperty=label/ /html:select But now trying to have a common function in the js file and pass an argument for the url it has to go to. what's is the right way of doing this? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts and javascript
On Thu, April 13, 2006 12:26 pm, Michael Jouravlev said: Or generate the target location in JSP like this: script language=javascript var mytarget = html:rewrite action=/PrepareSchedule.do/ /script That's a good option too. Then look up for target in your main Javascript function. I guess it would be easier to attach target to some well-know object like window, for example: window.mytarget = html:rewrite action=/PrepareSchedule.do/ FYI, I have experienced some problems with custom attributes on objects in some browsers. I suggest always using setAttribute()/getAttribute when working with custom attributes. Seems to be more cross-browser-friendly at this point. Frank -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts with javascript
When the HTMl page is rendered on screen, all the struts controls are rendered as normal HTMl controls. So u can refer them as document.forms [0].cadenaDesdeText.value. On 3/29/06, Jose Maria Tristan [EMAIL PROTECTED] wrote: Hi: I have a text: html:text property=cadenaDesdeText maxlength=10/. I need use this control in a function of javascript. Por example function showText(){ alert(cadenaDesdeText); } How can i use any control of struts into a function? How i can refer to the name of the control? Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts with javascript
ok. Thank you very much. -Mensaje original- De: Deepa Khetan [mailto:[EMAIL PROTECTED] Enviado el: miércoles, 29 de marzo de 2006 11:55 Para: Struts Users Mailing List Asunto: Re: Struts with javascript When the HTMl page is rendered on screen, all the struts controls are rendered as normal HTMl controls. So u can refer them as document.forms [0].cadenaDesdeText.value. On 3/29/06, Jose Maria Tristan [EMAIL PROTECTED] wrote: Hi: I have a text: html:text property=cadenaDesdeText maxlength=10/. I need use this control in a function of javascript. Por example function showText(){ alert(cadenaDesdeText); } How can i use any control of struts into a function? How i can refer to the name of the control? Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Struts Validator] JavaScript Validations
Have a look at http://www.roseindia.net/struts/address_struts_validator.shtml Regards Deepak Kumar --- Rosario, Blossom [EMAIL PROTECTED] wrote: Hi, I am trying to use client as well as server-side validations using the Struts Validator. The mapping in the Struts config file is actionpath=/register type=com.pampers.registration.action.RegisterAction name=registerForm scope=session validate=true input=/registration/reg_login.jsp parameter=method /action The corresponding reg_login.jsp page has the following lines to enable the client-side validations for the login page: html:form action=/register.do?method=login onsubmit=return validateRegisterForm(this); and html:javascript formName=registerForm/ Now, when I submit the login page, the client-side validations are not performed. When I do a view source, the dynamically generated validateRegisterForm function has the following code in it: script type=text/javascript language=Javascript1.1 !-- Begin var bCancel = false; function validateRegisterForm(form) { if (bCancel) return true; else return true; } //End -- /script This is a snippet of validation.xml form name=registerForm field property=userName depends=required arg0 key=label.email/ /field field property=password depends=required arg0 key=label.password/ /field /form Would appreciate if somebody could throw light as to why the client side validations are not being invoked. Thanks and Regards, Blossom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]