[appengine-java] Owned One to Many relationship problem: can not retrieve score value

2010-05-17 Thread bobo
Hi

As there's no any demo on relationship implementations on more than
one class in the download GAE files,  I feel pretty hard to try on the
JDO implementation with relationship classes.

I tried to use JDO to make an application with owned one to many
relationship.  That is, each QuizzTaker can take many Quizzes.
QuizzTaker acts as a parent and Quizz class is as child.  I also
created a utility class that would be called by a jsp page.  The jsp
page would be able to show the historic records for this taker: each
quizz name the taker has taken and the score he received for each
quizz.  The problem is that I can not retrieve score value and quizz
name.  I put the code below and anyone can shed me a light?

1. Quizz Class:
@PersistenceCapable
public class Quizz {
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
Key key;

@Persistent
private String quizzName;

@Persistent
private Integer score;

@Persistent
private QuizzTaker quizzTaker;

public Quizz( String qzName, Integer Score){
System.out.println(Quizz iniialization == +quizzName + | +
Score.intValue() );
this.quizzName = qzName;
this.score = Score;

}

public void setKey(Key key) {
this.key = key;
}

public Key getKey() {
return key;
}

public void setQuizzName(String quizzName) {
this.quizzName = quizzName;
}

public String getQuizzName() {
return quizzName;
}

public void setScore(Integer Score) {
this.score = Score;
System.out.println(Quizz is set score  + Score.intValue() );
}

public Integer getScore() {
return score;
}

}
2. QuizzTaker
@PersistenceCapable
public class QuizzTaker {
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
Key key;
@Persistent
private String userName;

@Persistent(mappedBy=quizzTaker)
@Order(extensions = @Extension(vendorName=datanucleus, key=list-
ordering, value=quizzName asc))
private CollectionQuizz quizzes;

public QuizzTaker(String userNickName){
this.setUserName(userNickName);
if(quizzes == null){
   quizzes = new ArrayListQuizz();
}
}

public void setKey(Key key) {
this.key = key;
}

public Key getKey() {
return key;
}

public void setQuizzes(Quizz quizz) {
quizzes.add(quizz);
}

public CollectionQuizz getQuizzes() {
return quizzes;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getUserName() {
return userName;
}


}

3. Utility class that JSP file will call those utility method:
public class QuizzUtils {


public static Quizz addNewUserToNewQuizz(String userName, String
quizzName, Integer score){
System.out.println(  addNewUserToNewQuizz );
PersistenceManager pm = PMF.get().getPersistenceManager();
Quizz quizz = null;
try{
pm.currentTransaction().begin();
try{
QuizzTaker qt = new QuizzTaker(userName);
Quizz qz = new Quizz(quizzName, score);
qz.setScore(score);
qt.setQuizzes(qz);
pm.makePersistent(qt);
}catch (JDOObjectNotFoundException e) {
System.out.println(e.getMessage());

}
pm.currentTransaction().commit();
}finally{
 if (pm.currentTransaction().isActive()) {
 pm.currentTransaction().rollback();
 }
 pm.close();
}
return quizz;

}

public static void addUserToQuizz(String userName, String quizzName,
Integer score){
System.out.println(  addUserToQuizz );
PersistenceManager pm = PMF.get().getPersistenceManager();
Quizz quizz = null;
try{
pm.currentTransaction().begin();
QuizzTaker qt = null;
try{
ListQuizz l_quizz = getQuizz(quizzName);
if(l_quizz.size() 0){
quizz = l_quizz.get(0);
}
ListQuizzTaker l_qt = getQuizzTaker(userName);
if(l_qt.size() 0){
  

[appengine-java] JSP code debug: Compiled JSP location in local environment

2010-05-04 Thread bobo
Hi

I got following error in my local enviroment of Google App Eng with
Eclipse plugin:
at org.apache.jsp.scoreresult_jsp._jspService(scoreresult_jsp.java:
161)

I would like to see the code on line 161 of compiled scoreresult.jsp
file. But I can't find out the location of it. Anyone can tell me
where the default folder locatoin for compiled .jsp files and also how
you debug jsp code when error is on .jsp but no error on your .java
file?

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] HTTP ERROR 405 with Guestbook Tutorial

2010-04-16 Thread bobo
Hi

I run Google App Engine (Java) locally with Eclipse.  Following the
tutorial of Getting Started - Java,  I lean it step by step and my
local server works well until the section Using JSPs.  After adding
SignGuestbookServlet.java and greeting form in guestbook.jsp as well
as editing web.xml for servlet mapping for sign and /sign,  I
restarted the server. My browser displayed error message immediately
after I tried to post a greeting message:

HTTP ERROR 405
Problem accessing /sign. Reason:HTTP method POST is not supported
by this URL

In Eclipse console,  the red error message like:
Apr 16, 2010 1:34:31 AM
com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /favicon.ico

I googled this error but seems no one having this problem before.  I
am stuck on this point and anyone who can shed me a light?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.