- This topic has 12 replies, 3 voices, and was last updated 21 years, 4 months ago by takai.
-
AuthorPosts
-
takaiMemberDoubt about Tags JavaBeans. 😥
Scott AndersonParticipantOk, I’m going to need more to go on than this. 🙂
–Scott
MyEclipse Support
takaiMemberHello.
I am using tags java bean with MyEclipse. But, I am have any problems.
1) This tags:
<%@page import=”com.taglib.wdjsp.faqtool.*” %>
<jsp:useBean id=”faq” class=”FaqBean”/>don’t work. It’s necessary full path in second tag:
<%@page import=”com.taglib.wdjsp.faqtool.*” %>
<jsp:useBean id=”faq” class=”com.taglib.wdjsp.faqtool.FaqBean”/>2) This tag:
<jsp:getProperty name=”faq” property=”ID”/>
don’t return a value correctly and the element [name=”faq”] is writing red.am I forget anything?
Thanks.
Scott AndersonParticipantIt’s necessary full path in second tag:
<%@page import=”com.taglib.wdjsp.faqtool.*” %>
<jsp:useBean id=”faq” class=”com.taglib.wdjsp.faqtool.FaqBean”/>That’s because this is what the JSP 2.0 spec requires. A full path must be used in the useBean tag.
1-97 PROPOSED FINAL DRAFT 3
The attribute beanName specifies the name of a Bean, as specified in the JavaBeans specification. It is used as an argument to the instantiate method in the java.beans.Beans class. It must be of the form a.b.c, which may be either a class, or the name of a resource of the form a/b/c.ser that will be resolved in the current ClassLoader. If this is not true, a request-time exception, as indicated in the
semantics of the instantiate method will be raised.2) This tag:
<jsp:getProperty name=”faq” property=”ID”/>
don’t return a value correctly and the element [name=”faq”] is writing red.Lack of support for the name attribute in the getProperty tag is a known bug and will be fixed in the next release. In the meantime, please ignore the red coloring.
–Scott
MyEclipse Support
takaiMemberHello Scot.
Ok. This meantime, I will use
<%=faq.getID()%>
instead of
<jsp:getProperty name=”faq” property=”ID”/>.
Isn’t it?
Thanks.
Scott AndersonParticipantThat will work fine, or you can also continue to use <jsp:getProperty>. The JSP will still execute correctly even though in EA2 it is colored as an error by the JSP editor. It won’t cause a runtime problem; it is just slightly misleading at the moment.
–Scott
MyEclipse Support
takaiMemberExcuse me dear Scot.
I used <jsp:getProperty name=”faq” property=”ID”/>, but it’s don’t returned any value!This scriptlets: <%=faq.getID()%> work, but replacing this scriptlets to this tag: <jsp:getProperty name=”faq” property=”ID”/>, don’t work.
Thanks.
Scott AndersonParticipantOK, thanks for clarifying it. Apparently the problem with recognizing the name attribute causes a runtime problem too. The scriplet is a good workaround for this, as you suggested.
–Scott
MyEclipse Support
Wayne KiddMemberI think it would be interesting to know what the field in
com.taglib.wdjsp.faqtool.FaqBean is defined as.
iif the field is “id” or “ID” then there may be a problem.
If the field is id, then the right way to refer to it is with a method called
getId not getID. Javabeans are based on introspection. Convention says to name fields beginning with lowercase letters and that the accessor should uppercase the first letter of the field and leave the rest alone. The javabeans introspection kind of depends on it.Wayne
Scott AndersonParticipantWayne,
Very good catch. I believe this may be the exact problem that he’s experiencing with the getProperty tag.
Thanks for the help.
–Scott
MyEclipse Support
takaiMemberHello Wayne and Scott.
My FaqBean method is:
public int getID() {
return this.id;
}
When press ctrl+space in <%=faq.
myeclipe editor return getID.
It’s correct, isn’t it?
Thanks.
Scott AndersonParticipantJust as an experiment, try adding the following method to your bean:
public int getId() { return this.id; }Then, try this in your JSP page:
<jsp:getProperty name=”faq” property=”id”/>These changes will make your bean conform to the naming convention used in the spec.
–Scott
MyEclipse Support
takaiMemberHello Scot.
I realized this test. Unfortunately, this don’t worked. The return value was 0 (zero).
Thanks a lot.
Takai. -
AuthorPosts