?
Solved

struts bean write tag cannot find the bean while iterating messages

Posted on 2005-05-14
5
Medium Priority
?
553 Views
Last Modified: 2010-05-18
Hi, I am having trouble using <bean:write> while iterating <html:messages>, any help is appreciated.

The following prints "foobar", that means there is a message with property "nameTooShort".
                           <logic:messagesPresent message="true">
                              foo
                             <html:messages id="msg" property="nameTooShort" message="true">
                              bar
                             </html:messages>
                           </logic:messagesPresent>
                         </td></tr>

However, the following gives an exception that the bean "msg" cannot be found in any scope:
                           <logic:messagesPresent message="true">
                              foo
                             <html:messages id="msg" property="mrn" message="true">
                                 bar
                                <bean:write name="msg"/>
                             </html:messages>
                           </logic:messagesPresent>

javax.servlet.ServletException: Cannot find bean msg in any scope
        at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
        at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
        at org.apache.jsp.secure.patient.search_005fc_jsp._jspService(search_005fc_jsp.java:237)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)
0
Comment
Question by:kkealoha
  • 2
  • 2
4 Comments
 

Author Comment

by:kkealoha
ID: 14003715
Sorry, had a typo, so reposting.....
Hi, I am having trouble using <bean:write> while iterating <html:messages>, any help is appreciated.

The following prints "foobar", that means there is a message with property "nameTooShort".
                           <logic:messagesPresent message="true">
                              foo
                             <html:messages id="msg" property="nameTooShort" message="true">
                              bar
                             </html:messages>
                           </logic:messagesPresent>
                         </td></tr>

However, the following gives an exception that the bean "nameTooShort" cannot be found in any scope:
                           <logic:messagesPresent message="true">
                              foo
                             <html:messages id="msg" property="nameTooShort" message="true">
                                 bar
                                <bean:write name="msg"/>
                             </html:messages>
                           </logic:messagesPresent>

javax.servlet.ServletException: Cannot find bean msg in any scope
        at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
        at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
        at org.apache.jsp.secure.patient.search_005fc_jsp._jspService(search_005fc_jsp.java:237)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)
0
 
LVL 16

Accepted Solution

by:
suprapto45 earned 375 total points
ID: 14004576
Hi,

How do you send your "nameTooShort" from your ActionForm or Action?

Regards
Dave

0
 

Author Comment

by:kkealoha
ID: 14004810
I am doing the following:

        ActionMessages msgs = new ActionMessages ();
        msgs.add ("nameTooShort", new ActionMessage ("error.psearch.nametooshort"));
        saveMessages (request, msgs);
        return mapping.findForward (C.Forward.PATIENT_SEARCH);

Your question made me look at my code in more detail, I had a spelling error in the property name "nameTooShort" in the MessageResources.properties file.  All works fine now.  Thanks.
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 14007549
Hi,

Glad you can solve it by yourself.

Regards
Dave
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question