Hi,

try changing "ID" to "Id". The thing is that following JavaBeans specification,
only the first letter of the variable has to be capitalized.
For example:
If your bean has a variable "question", the setter method will be "setQuestion",
the getter method will be "getQuestion", i.e. the first letter of your variable
"question" is turned into a capital letter

So, following the same rules, if your variable is "id", the set and get methods
must be "setId" and "getId".

HTH

Anne-Marie

Ying Sun wrote:

> Hi all,
> I happened to a strange problems.
> The command prompt window display every bean id and question as expected from
> database.
> but the <jsp:getProperty name="faq" property="ID">
>            <jsp:getProperty name="faq" property="question"> doesn't work,
> it suppose look like
> id       question
> 1        what's this
> 2       what's that
>
> but now it look like
> id
> 0
> 0
>
> and also the bean property is id,why we need to put ID in <jsp:getProperty
> name="faq" property="ID"> .
>
> thank you all in advance
>
> <%@ page import="com.taglib.wdjsp.faqtool.*"
> errorPage="error.jsp" %>
> <jsp:useBean id="faq" class="com.taglib.wdjsp.faqtool.FaqBean"/>
> <%
>   FaqBean[] faqs = (FaqBean[])request.getAttribute("faqs");
> %>
> <html>
> <head><title>Update Menu</title></head>
> <form name="menu" action="/webdev/servlet/FaqAdminServlet" method="post">
> <table border="1" align="center"><tr><td>
> <table bgcolor="tan" border="1" align="center" cellpadding="10"
> cellspacing="0">
> <tr><th colspan="2">FAQ Administration: Update Menu</th></tr>
> <%
> for (int i=0; i < faqs.length; i++) {
>   faq = faqs[i];
> %>
> <% System.out.println(faq.getID()); %>
> <% System.out.println(faq.getQuestion()); %>
> <tr>
> <td><input type="radio" name="id" value="<jsp:getProperty name="faq"
> property="ID"/>">
> <jsp:getProperty name="faq" property="ID"/></td>
> <td><jsp:getProperty name="faq" property="question"/></td>
> </tr>
> <% } %>
> <tr><td colspan=2 align="center">
> <input type="submit" value="Abort Updating">
> <input type="submit" value="Update Selected FAQ"
> onClick="document.menu.cmd.value='update'">
> </td></tr>
> </table>
> </td></tr></table>
> <input type="hidden" name="cmd" value="abort">
> </form>
> </html>
>
> package com.taglib.wdjsp.faqtool;
>
> import java.util.Date;
>
> public class FaqBean {
>   private int id;
>   private String question;
>   private String answer;
>   private Date lastModified;
>
>   public FaqBean() {
>     this.id = 0;
>     this.question = "";
>     this.answer = "";
>     this.lastModified = new Date();
>   }
>
>   public void setQuestion(String question) {
>     this.question = question;
>     this.lastModified = new Date();
>   }
>
>   public String getQuestion() {
>     return this.question;
>   }
>
>   public void setAnswer(String answer) {
>     this.answer = answer;
>     this.lastModified = new Date();
>   }
>
>   public String getAnswer() {
>     return this.answer;
>   }
>
>   public void setID(int id) {
>     this.id = id;
>   }
>
>   public int getID() {
>     return this.id;
>   }
>
>   public Date getLastModified() {
>     return this.lastModified;
>   }
>
>   public void setLastModified(Date modified) {
>     this.lastModified = modified;
>   }
>
>   public String toString() {
>     return "[" + id + "] " + "Q: " + question + "; A: " +
>       answer + "\n";
>   }
> }

--
=====================================
Anne-Marie Ternes

Informaticien diplômé

Centre Informatique de l'Etat
B.P. 1111
L-1011 Luxembourg

Tél: 49 925 642
E-Mail: [EMAIL PROTECTED]
=====================================


Reply via email to