- This topic has 12 replies, 3 voices, and was last updated 22 years ago by
takai.
-
AuthorPosts
-
takaiMemberDoubt about Tags JavaBeans. 😥
June 28, 2003 at 5:19 pm #196545
Scott AndersonParticipantOk, I’m going to need more to go on than this. 🙂
–Scott
MyEclipse SupportJune 28, 2003 at 5:24 pm #196546
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.June 28, 2003 at 6:18 pm #196547
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 SupportJune 28, 2003 at 7:19 pm #196548
takaiMemberHello Scot.
Ok. This meantime, I will use
<%=faq.getID()%>
instead of
<jsp:getProperty name=”faq” property=”ID”/>.
Isn’t it?
Thanks.June 28, 2003 at 7:34 pm #196549
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 SupportJune 28, 2003 at 8:25 pm #196550
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.
June 28, 2003 at 8:51 pm #196551
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 SupportJune 28, 2003 at 11:54 pm #196552
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
June 29, 2003 at 3:23 pm #196559
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 SupportJune 29, 2003 at 6:37 pm #196561
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.June 30, 2003 at 8:25 am #196562
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 SupportJune 30, 2003 at 7:33 pm #196580
takaiMemberHello Scot.
I realized this test. Unfortunately, this don’t worked. The return value was 0 (zero).
Thanks a lot.
Takai. -
AuthorPosts