wood burning stoves 2.0*
The moose likes Struts and the fly likes need help while using <nested:write> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "need help while using <nested:write>" Watch "need help while using <nested:write>" New topic
Author

need help while using <nested:write>

Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
hello rancher,
here i am stuck in problem while using <nested:write>tag. here i am trying to pass the value of "filterNo"(propery of filterEntry bean) to an javascript function called onCheck(). but this gives me some syntex error (javascript syntex error), which i am not able to solve. <nested:write> is not working here while using it to pass to a javascript function.




thanks in advance
Poonam

Thanks <br />Poonam Agarwal SCWCD 86%
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Looks like you have the nested:write in a scriptlet, that won't work, but it shouldn't be a problem because it doesn't look like you need that value in a scriptlet anyway since its the only thing in the scriptlet, try removing the tags for the scriptlet (the <%= and hte %>).


Hope that helps.
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
Tom Rispoli wrote:Looks like you have the nested:write in a scriptlet, that won't work, but it shouldn't be a problem because it doesn't look like you need that value in a scriptlet anyway since its the only thing in the scriptlet, try removing the tags for the scriptlet (the <%= and hte %>).


Hope that helps.


thanks tom for your effort. you want me to remove scriplets tag ??
like this??
onclick="onCheck('<nested:write name='filterEntry' property='filterNo'>')" is there any other way to pass a value of filterNo to a javascript function without using nested:write tag??

please reply. thanks in advance
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Scriptlet tags don't really have anything to do with javascript, they indicate code that will get put into the java program generated by your JSP. Doing this:

onclick="onCheck('<nested:write name='filterEntry' property='filterNo'>')

should cause your JSP to generate an html response to your browser that will set up the onclick event of your tag to call onCheck('some value'), which I think is what you want. Do this and check your html source to see if you are getting what you want in there.


Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
I am really very sorry to bug you so much. but i am very novice to struts.
when I try to run this
onclick="onCheck("<nested:write name="filterEntry" property="filterNo"/>")"/>
OR
onclick="onCheck('<nested:write name="filterEntry" property="filterNo"/>')"/>

it keeps giving me the " equal symbol expected' " error. I also tried another way to get the value of filterNo by using <nested:define> tag.
please help me out how do I solve it.

Thanks in advance
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Oops I missed an important detail when I was looking at your code, I think the main problem here is that I don't think you can use the nested:write inside the nested:checkbox tag. Sorry, I didn't notice you were in a nested:checkbox tag. I think you were on the right track with teh nested:define tag. I think you'll need to use it to define another variable and then use that variable in a scriptlet in that on check method. Something like this I think:



Sorry for the confusion.
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
tom, I am really very thankfull to you for your help to resolve this issue. thanks for making my doubt clear.

YOU RoCKS Buddy
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
hey tom, thanks again for solving my doubt.
I encoutered an expected problem after making this change


when I deploy my updated code to some different environment that is a webshere server this line of code onclick="<%="onCheck(" + CheckedFilterNo + ")"%>" gives me error (Unable to create an xml attribute from name [onCheck(] value [ + CheckedFilterNo + ]).
JSP Processing Error
HTTP Error Code: 500


Error Message:/WEB-INF/search.jsp(380,135) JSPG0055E: Unable to create an xml attribute from name [onCheck(] value [ + CheckedFilterNo + ]

Root Cause:com.ibm.ws.jsp.JspCoreException: /WEB-INF/search.jsp(380,135) JSPG0055E: Unable to create an xml attribute from name [onCheck(] value [ + CheckedFilterNo + ] at com.ibm.ws.jsp.translator.document.Jsp2Dom.getJspDocumentAsJspPage(Jsp2Dom.java:300) at com.ibm.ws.jsp.translator.document.Jsp2Dom.getJspDocument(Jsp2Dom.java:179) at com.ibm.ws.jsp.translator.JspTranslator.<init>(JspTranslator.java:73) at com.ibm.ws.jsp.translator.JspTranslatorFactory.createTranslator(JspTranslatorFactory.java:116) at com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJsp(JspTranslatorUtil.java:193) at com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJspAndCompile(JspTranslatorUtil.java:93) at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.translateJsp(JSPExtensionServletWrapper.java:397) at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper._checkForTranslation(JSPExtensionServletWrapper.java:366) at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.checkForTranslation(JSPExtensionServletWrapper.java:274) at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:151) at com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor.handleRequest(JSPExtensionProcessor.java:255) at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:670)


please check error description. I have no clue about it.

Thanks in advance
Poonam
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
try using single quotes around your onclick event instead of double quotes, like this:

onclick='<%="onCheck(" + CheckedFilterNo + ")"%>'
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
It works.. thanks again. !
I want to know what is the actual cause of this processing error??
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I think the issues is that you can use either a single or double quote to mark the begining and end of the onclick event. However if you have a scriptlet with double quotes in it in the JSP then the JSP gets confused when it tries to generate the code for it if you start the onclick event with double quotes. The JSP will think the first set of double quotes in the scriptlet is actually the end of the onclick event. Once it makes that mistake it won't be able to understand the rest of the line. At least thats my assumption, its based on the other times that I've run into the same thing, and switching to single quotes seems to fix it.
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
thanks for making doubt clear. actually i am working on a stucts project without having more knowldge about it. I want to learn struts from start.
kindly guide me with some notes or refer me some books on it ..

thanks Again for all your effort

Poonam
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
At the top of this forum there are links to the Struts home page and an FAQ for the forum. I got most of my understanding from working just trying to work with struts and using the struts web site as a reference (although I did spend a lot of time wishing I had a better understanding of how struts worked). I bought "The Complete Reference - Struts" when I started, its published by McGraw Hill, I do NOT recomend it. For the most part it is the same stuff that you can get from the Struts web site. The FAQ for the forum makes some suggestions about what books might be helpful try checking there if you haven't already.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
At the top of this forum there are links to the Struts home page and an FAQ for the forum. I got most of my understanding from working just trying to work with struts and using the struts web site as a reference (although I did spend a lot of time wishing I had a better understanding of how struts worked). I bought "The Complete Reference - Struts" when I started, its published by McGraw Hill, I do NOT recomend it. For the most part it is the same stuff that you can get from the Struts web site. The FAQ for the forum makes some suggestions about what books might be helpful try checking there if you haven't already.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help while using <nested:write>
 
Similar Threads
how to group <nested:radio> tag
logic tag inside nested:iteration tag
BeanUtils.populate IndexOutofBound
INDEX PROPERTY <html:form> with nested beans
logic tag inside nested:iteration tag