コード例 #1
0
ファイル: Moldable.cpp プロジェクト: reolyze/Mogu
void Moldable::__validate()
{
    Wt::WLineEdit* input = (Wt::WLineEdit*) widget(0);
    Wt::WValidator::State result = input->validate();
    if (result == Wt::WValidator::Valid)
    {
        __succeeded_test.emit();
        return;
    }
    __failed_test.emit();
} // validate
コード例 #2
0
ファイル: CommentsWidget.cpp プロジェクト: starius/facts
 void add_handler_() {
     Wt::WValidator::State V = Wt::WValidator::Valid;
     if (username_->validate() != V) {
         error_->setText(tr("facts.comment.Incorrect_username"));
         return;
     }
     if (email_->validate() != V) {
         error_->setText(tr("facts.comment.Incorrect_email"));
         return;
     }
     int input_length = text_->text().value().size();
     if (input_length < MIN_INPUT_SIZE || input_length > MAX_TEXT_SIZE) {
         error_->setText(tr("facts.comment.Incorrect_text"));
         return;
     }
     dbo::Transaction t(fApp->session());
     if (fApp->is_banned()) {
         error_->setText(tr("facts.common.BannedIp"));
         return;
     }
     int index;
     if (comments_->fact()->comments().size()) {
         index = 1 + fApp->session()
                 .query<int>("select max(comment_index) from facts_comment where fact_id=?")
                 .bind(comments_->fact().id());
     } else {
         index = 1;
     }
     CommentPtr c = fApp->session().add(new Comment(CommentId(comments_->fact(), index)));
     c.modify()->set_username(username_->text());
     c.modify()->set_email(email_->text().toUTF8());
     c.modify()->set_text(text_->text());
     c.modify()->set_ip(fApp->environment().clientAddress());
     comments_->comment_added_handler_(); // delete this
     t.commit();
 }