You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Daniel Watrous <da...@gmail.com> on 2012/01/21 22:35:22 UTC

guestbook application with database update

I'm creating a small app based on the guestbook:
http://www.wicket-library.com/wicket-examples/guestbook/?1

In the guestbook app, the page view is updated every time a new
comment is added. The variable commentList is initialized at the top
like this

private static final List<Comment> commentList = new ArrayList<Comment>();

        // Add commentListView of existing comments
        add(new PropertyListView<Comment>("comments", commentList)
        {
            @Override
            public void populateItem(final ListItem<Comment> listItem)
            {
                listItem.add(new Label("date"));
                listItem.add(new MultiLineLabel("text"));
            }
        }).setVersioned(false);

I wanted to use a database instead, so I made the following changes

private List<Movie> movieList = new ArrayList<Movie>();

        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        movieList = session.createQuery("from Movie").list();
        session.getTransaction().commit();

        // Add commentListView of existing comments
        add(new PropertyListView<Movie>("movies", movieList) {

            @Override
            public void populateItem(final ListItem<Movie> listItem) {
                listItem.add(new
TextField<String>("name").setType(String.class));
                listItem.add(new DropDownChoice<Category>("category",
Arrays.asList(Category.values()), new
EnumChoiceRenderer<Category>(this)));
                listItem.add(new Label("rating"));
            }
        }).setVersioned(false);

With this change, all the items in the database come up when the page
first loads, but not after each new item is added to the database. I
have to clear out the URL and load the page fresh to see what has been
added since the last fresh load.

I did try resetting movieList in the onSubmit function to load the
current database items into the variable movieList, but that still
doesn't update the list.

Any idea how to update movieList after each new item is submitted.

Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: guestbook application with database update

Posted by Jeremy Thomerson <je...@wickettraining.com>.
For future reference in case somebody stumbles across this post: this guy
was moderated through, which requires a different remove command.  Martijn
pointed out that the command for that is for a list moderator to email:
users-allow-unsubscribe-jaffa.wify=gmail.com@wicket.apache.org

Thanks Martijn!

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

On Mon, Jun 25, 2012 at 3:08 PM, Jeremy Thomerson <jeremy@wickettraining.com
> wrote:

> All list moderators do.  I just emails to users-unsubscribe-jaffa.wify=
> gmail.com@wicket.apache.org and users-deny-subscribe-jaffa.wify=
> gmail.com@wicket.apache.org which I think will block this guy.
>
> More info: http://www.apache.org/dev/committers.html#problem_posts
>
> --
> Jeremy Thomerson
> http://wickettraining.com
> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
>
>
>
> On Thu, Jun 21, 2012 at 7:30 AM, Martin Grigorov <mg...@apache.org>wrote:
>
>> This looks like a spam.
>> Third mail in this thread with unrelated content.
>> Who has the karma to block this user ?
>>
>> On Thu, Jun 21, 2012 at 3:23 PM, jaffa <ja...@gmail.com> wrote:
>> > Names and addresses provided in guestbooks, paper based or electronic,
>> are
>> > frequently recorded and collated for use in providing statistics about
>> > visitors to the site, and to contact visitors to the site in the future.
>> > Thanks.
>> > Regards,
>> > http://www.webryze.com toronto online marketing
>> >
>> >
>> > --
>> > View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/guestbook-application-with-database-update-tp4316943p4650155.html
>> > Sent from the Users forum mailing list archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>

Re: guestbook application with database update

Posted by Jeremy Thomerson <je...@wickettraining.com>.
All list moderators do.  I just emails to users-unsubscribe-jaffa.wify=
gmail.com@wicket.apache.org and users-deny-subscribe-jaffa.wify=
gmail.com@wicket.apache.org which I think will block this guy.

More info: http://www.apache.org/dev/committers.html#problem_posts

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*



On Thu, Jun 21, 2012 at 7:30 AM, Martin Grigorov <mg...@apache.org>wrote:

> This looks like a spam.
> Third mail in this thread with unrelated content.
> Who has the karma to block this user ?
>
> On Thu, Jun 21, 2012 at 3:23 PM, jaffa <ja...@gmail.com> wrote:
> > Names and addresses provided in guestbooks, paper based or electronic,
> are
> > frequently recorded and collated for use in providing statistics about
> > visitors to the site, and to contact visitors to the site in the future.
> > Thanks.
> > Regards,
> > http://www.webryze.com toronto online marketing
> >
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/guestbook-application-with-database-update-tp4316943p4650155.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: guestbook application with database update

Posted by Martin Grigorov <mg...@apache.org>.
This looks like a spam.
Third mail in this thread with unrelated content.
Who has the karma to block this user ?

On Thu, Jun 21, 2012 at 3:23 PM, jaffa <ja...@gmail.com> wrote:
> Names and addresses provided in guestbooks, paper based or electronic, are
> frequently recorded and collated for use in providing statistics about
> visitors to the site, and to contact visitors to the site in the future.
> Thanks.
> Regards,
> http://www.webryze.com toronto online marketing
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/guestbook-application-with-database-update-tp4316943p4650155.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: guestbook application with database update

Posted by jaffa <ja...@gmail.com>.
Names and addresses provided in guestbooks, paper based or electronic, are
frequently recorded and collated for use in providing statistics about
visitors to the site, and to contact visitors to the site in the future.
Thanks.
Regards,
http://www.webryze.com toronto online marketing 


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/guestbook-application-with-database-update-tp4316943p4650155.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: guestbook application with database update

Posted by kamiseq <ka...@gmail.com>.
it really doesnt matter where you get your data - from ArrayList or db
- wrap code to access db into some function that return List and use
LoadableDetachableModel as sven advised

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: guestbook application with database update

Posted by jaffa <ja...@gmail.com>.
Graph databases are based on graph theory. Graph databases employ nodes,
properties, and edges. Nodes are very similar in nature to the objects that
object oriented programmers will be familiar with. Thanks.
Regards,
http://www.johnbeckwiki.com

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/guestbook-application-with-database-update-tp4316943p4650025.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: guestbook application with database update

Posted by jaffa <ja...@gmail.com>.
The graph database is a kind of NoSQL database that uses graph structures
with nodes, edges, and properties to represent and store information.
General graph databases that can store any graph are distinct from
specialized graph databases such as triplestores and network databases.
Thanks.
Regards,
http://www.academicwritinghelp.biz/essay-writing-help/ essay writing help 


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/guestbook-application-with-database-update-tp4316943p4649899.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: guestbook application with database update

Posted by Daniel Watrous <da...@gmail.com>.
This worked GREAT! Thank you.

On Sat, Jan 21, 2012 at 2:51 PM, Sven Meier <sv...@meiers.net> wrote:
> Use a LoadableDetachableModel to load a fresh list of movies on each
> request.
>
> Sven
>
>
> On 01/21/2012 10:35 PM, Daniel Watrous wrote:
>>
>> I'm creating a small app based on the guestbook:
>> http://www.wicket-library.com/wicket-examples/guestbook/?1
>>
>> In the guestbook app, the page view is updated every time a new
>> comment is added. The variable commentList is initialized at the top
>> like this
>>
>> private static final List<Comment>  commentList = new
>> ArrayList<Comment>();
>>
>>         // Add commentListView of existing comments
>>         add(new PropertyListView<Comment>("comments", commentList)
>>         {
>>             @Override
>>             public void populateItem(final ListItem<Comment>  listItem)
>>             {
>>                 listItem.add(new Label("date"));
>>                 listItem.add(new MultiLineLabel("text"));
>>             }
>>         }).setVersioned(false);
>>
>> I wanted to use a database instead, so I made the following changes
>>
>> private List<Movie>  movieList = new ArrayList<Movie>();
>>
>>         Session session =
>> HibernateUtil.getSessionFactory().getCurrentSession();
>>         session.beginTransaction();
>>         movieList = session.createQuery("from Movie").list();
>>         session.getTransaction().commit();
>>
>>         // Add commentListView of existing comments
>>         add(new PropertyListView<Movie>("movies", movieList) {
>>
>>             @Override
>>             public void populateItem(final ListItem<Movie>  listItem) {
>>                 listItem.add(new
>> TextField<String>("name").setType(String.class));
>>                 listItem.add(new DropDownChoice<Category>("category",
>> Arrays.asList(Category.values()), new
>> EnumChoiceRenderer<Category>(this)));
>>                 listItem.add(new Label("rating"));
>>             }
>>         }).setVersioned(false);
>>
>> With this change, all the items in the database come up when the page
>> first loads, but not after each new item is added to the database. I
>> have to clear out the URL and load the page fresh to see what has been
>> added since the last fresh load.
>>
>> I did try resetting movieList in the onSubmit function to load the
>> current database items into the variable movieList, but that still
>> doesn't update the list.
>>
>> Any idea how to update movieList after each new item is submitted.
>>
>> Daniel
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: guestbook application with database update

Posted by Sven Meier <sv...@meiers.net>.
Use a LoadableDetachableModel to load a fresh list of movies on each 
request.

Sven

On 01/21/2012 10:35 PM, Daniel Watrous wrote:
> I'm creating a small app based on the guestbook:
> http://www.wicket-library.com/wicket-examples/guestbook/?1
>
> In the guestbook app, the page view is updated every time a new
> comment is added. The variable commentList is initialized at the top
> like this
>
> private static final List<Comment>  commentList = new ArrayList<Comment>();
>
>          // Add commentListView of existing comments
>          add(new PropertyListView<Comment>("comments", commentList)
>          {
>              @Override
>              public void populateItem(final ListItem<Comment>  listItem)
>              {
>                  listItem.add(new Label("date"));
>                  listItem.add(new MultiLineLabel("text"));
>              }
>          }).setVersioned(false);
>
> I wanted to use a database instead, so I made the following changes
>
> private List<Movie>  movieList = new ArrayList<Movie>();
>
>          Session session = HibernateUtil.getSessionFactory().getCurrentSession();
>          session.beginTransaction();
>          movieList = session.createQuery("from Movie").list();
>          session.getTransaction().commit();
>
>          // Add commentListView of existing comments
>          add(new PropertyListView<Movie>("movies", movieList) {
>
>              @Override
>              public void populateItem(final ListItem<Movie>  listItem) {
>                  listItem.add(new
> TextField<String>("name").setType(String.class));
>                  listItem.add(new DropDownChoice<Category>("category",
> Arrays.asList(Category.values()), new
> EnumChoiceRenderer<Category>(this)));
>                  listItem.add(new Label("rating"));
>              }
>          }).setVersioned(false);
>
> With this change, all the items in the database come up when the page
> first loads, but not after each new item is added to the database. I
> have to clear out the URL and load the page fresh to see what has been
> added since the last fresh load.
>
> I did try resetting movieList in the onSubmit function to load the
> current database items into the variable movieList, but that still
> doesn't update the list.
>
> Any idea how to update movieList after each new item is submitted.
>
> Daniel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: guestbook application with database update

Posted by jaffa <ja...@gmail.com>.
Renaissance painters used the camera obscura which, in fact, gives the
optical rendering in color that dominates Western Art. The camera obscura
literally means dark chamber in Latin. It is a box with a hole in it which
allows light to go through and create an image onto the piece of paper.
Thanks.
Regards,
http://	http://www.sixsingles.com dating sites 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/guestbook-application-with-database-update-tp4316943p4650239.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org