how to avoid exception when the bean is not define yet?
Hi all,
wonder how to avoid an exception when the bean is not define yet?
<bean:write name="criteria_level_1" property="page" />
also, how can I provide a link to the bean? meaning if the bean exists I would like the end user to click the information presented and refer to a url.
thank you!
# 1
I'm just trying to help, but first I need to understand a few things
is <bean:write a struts tag?
In JSP one uses ><jsp:useBean to first create an instance of the bean in the JSP and then they use ><jsp:setProperty to set the property.
Is that what you're looking for?
What error message are you getting?>
# 2
is <bean:write a struts tag?
yes
ServletException in:/pages/deals/content/ticketLevel.jsp] Cannot find bean criteria_level_1 in any scope' javax.servlet.ServletException: Cannot find bean criteria_level_1 in any scope at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858) at>
# 3
Sorry, I don't know struts yet :-( I guess someone else might be able to help you.If you don't get a reply soon, try the Struts User Mailing list here: http://struts.apache.org/mail.htmlMessage was edited by: appy77
# 5
Well there is always the logic:present tag, or a JSTL c:if may be more appropriate.
Using logic:present. Will only evaluate the body if the bean "criteria_level_1" is defined
<logic:present name="criteria_level_1">
<bean:write name="criteria_level_1" property="page" />
</logic:present>
The JSTL c:if tag is a lot more flexible than the logic:present tag, and is generally preferred.
<c:if test="${not empty criteria_level_1}">
<bean:write name="criteria_level_1" property="page" />
</c:if>
>also, how can I provide a link to the bean?
Well you can't link to the bean directly, but you could create a link to a jsp page which would load and display information about that bean.
You could do so either with standard html, or using the <html:link> tag from struts.
Cheers,
evnafets