plainblack.com
Username Password
search
Bookmark and Share

    

possible wobject tutorial error

User rbroen
Date 4/3/2007 6:57 am
Views 2810
Rating 4    Rate [
|
]
Previous · Next
User Message
rbroen
I've seen something in the trivia.pm example on the site, that puzzles me...

sub www_deleteQuestion {
    my $self = shift;
    my ($privilege, $form, $db) = $self->session->quick("privilege", "form", "db");
    return $privilege->insufficient() unless ($self->canEdit);
    $db->write("delete from Trivia_answer where questionId=?", $form->param("answerId"));
    $self->deleteCollateral("Trivia_question","questionId", $form->param("questionId"));
    return $self->www_view;
}

 

Shouldn't the fifth line be: 

$db->write("delete from Trivia_answer where questionId=?", $form->param("questionId")); 

 

This goes for the trivia.pm download as well as the tutorial online.

 Thank you for any help. 



Back to Top
Rate [
|
]
 
 
JT
You are correct. I'll get the tutorial changed.


Back to Top
Rate [
|
]
 
 
rbroen

Cool, thank you.

Maybe you can shine a light on this one too...  There is a line in the www_editQuestion methode that seems to be put there to be able to add answers to existing questions.

$ac->addSubmenuItem($self->getUrl("func=editAnswer;questionId=" . $question->{questionId}.";answerId=new"),"Add a new answer."); 

While testing this, you guessed it, I couldn't add answers to existing questions...



Back to Top
Rate [
|
]
 
 
JT
I don't know what you mean by "couldn't add answers to existing questions". Does this mean you couldn't see the link? Or that you clicked on the link and nothing happened? Or that you clicked on the link and saw the edit form, but couldn't save it? Something else? Were any errors displayed on screen? In the WebGUI log? In the Apache log?

Back to Top
Rate [
|
]
 
 
rbroen
I apologize for not being more clear.

The Trivia example lets webmasters add trivia questions to their site. After setting up a question, they might want to add an answer (the next day or so) to one of their questions. The line I mentioned earlier should enable this... but it is not present where it should be. No errors in sight.

Back to Top
Rate [
|
]
 
 
JT

Where do you think it should be?

It should be showing up as an item in the admin console menu on the right side of the screen. 



Back to Top
Rate [
|
]
 
 
rbroen

Ok, i have found it!

 

I looked for it yesterday, but missed it. That's not a really good place from a UI point of view, but a great place if you want to show me how to start developing.

Thanx!



Back to Top
Rate [
|
]
 
 
rbroen

I'm almost done with the tutorial, but would like to ask you two more questions:

 1) Collateral - The tutorial uses get- and putCollateral methodes, but the first part of the Asset documentation states: "Package to manipulate items in WebGUI's asset system. Replaces Collateral.".

 Is Collateral a deprecated?

 2) Should placeholders be placed in an array?

In "www_deleteQuestion {}" I found the following line with a plain placeholder:

$db->write("delete from Trivia_answer where questionId=?", $form->param("questionId")); 

In "sub prepareView{}" I found the following line (placeholder in an array ref):

my $sth = $db->read("select answerId,answer from Trivia_answer where questionId=?",[$question->{questionId}]); 

 



Back to Top
Rate [
|
]
 
 
    



© 2012 Plain Black Corporation | All Rights Reserved