I don't call them directly *with* the querystring...I called this up in a browser:

http://localhost:8080/MyApp/edit_product

...which jumped to:

http://localhost:8080/MyApp/edit_product?path=1

and threw the exception.

You mean to say that I could *never* safely call a url of an Application I've mapped in web.xml like this:

http://localhost:8080/MyApp/edit_product

where "edit_product" is mapped to my Application class/servlet?

On 3/15/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
you cannot call the page standalaone from the browser. wicket doesnt work that way. the /only/ pages you can call yourself are the bookmarkable pages that have a stable url.

the ?path... urls are internal and the same url can point to different pages dependent on what the session state is. you should never call those urls directly.


-Igor


On 3/15/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
I still must not be understanding you entirely.  It makes sense but here's an example of what I'm doing and I'm still getting an exception:

My URL looks like this (non-bookmarkable):

http://localhost:8080/MyApp/edit_product?path=1

The class has no default constructor...it has only one that looks like this:

public class EditProduct extends WebPage
{
    public EditProduct(Product editProduct)
    {       
....

I get this exception:

wicket.WicketRuntimeException: Unable to instantiate Page class:
...
Caused by: wicket.WicketRuntimeException: Unable to create page from class ... Class does not have a default contructor

Alright, fair enough, so I add one:

public class EditProduct extends WebPage
{
    /**
     * default ctor
     *
     */
    public EditProduct()
    {
       
    }
   
    public EditProduct(Product editProduct)
    {       
.....

And now I get this exception:


wicket.markup.MarkupException: Unable to find component with id 'headerPanel' in...

Which must mean that all of my component additions should be in the default ctor, right?

This page isn't being instantiated through setResponsePage, I'm just calling it up in a browser, stand alone, but I'm assuming that shouldn't matter since I'm not using a bookmarked URL.


Thanks again!

On 3/15/06, Igor Vaynberg <[EMAIL PROTECTED] > wrote:
when you do setResponsePage(Class) a bookmarkable url is created and the page instance will be created through the default or the (PageParameters) constructor. when you do setResponsePage(new MyPage())  you create the instance yourself with any constructor you want and a non-bookmarkable url will be used.


-Igor


On 3/15/06, Vincent Jenks < [EMAIL PROTECTED]> wrote:
I see, I'll try it again.  So, that being said, when can I be sure I'm not using a bookmarkable page?  I noticed that on some requests the "bookmarkable "querystring is used and on others...the "path" is used.

I apologize if I'm asking annoying n00b questions, I'm trying to cram Wicket into my head and into a small proof-of-concept project to convince my boss to let me use it on future projects (now that we're migrating to Java.)

Thanks again!


On 3/15/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
sounds like you are on the right place. you dont have to use the default constructor. the default/PageParameters constructor is only needed if this page is going to be accessed through a bookmarkable url. outside of that you are welcome to use any constructor you want.

-Igor



On 3/15/06, Vincent Jenks <[EMAIL PROTECTED]> wrote:
I'm trying to wrap my head around how I would create a page where I could either edit an existing record or create a new one.

Currently, I've got a form where I can add a record to the database - that part is working great.  I'd like to refactor it now to also edit an existing record, if there is one.  The user would choose a record from a ListView below the form and the form would be populated w/ the values of that entity bean.  The user would change values and then submit the form.

My first idea was to pass the object into the constructor of the page class:

public EditProduct(Product editProduct)

...and then decide inside the constructor whether or not to create a new Product object or use the one passed in:

        //edit or new?
        Product p = null;       
        if (editProduct == null)
            p = new Product();
        else
            p = editProduct;

I would then pass the Product into the form:

add(new EditProductForm("editProductForm", p));

...which would be bound like so:

        public EditProductForm(String name, Product product)
        {
            super(name, new CompoundPropertyModel(product));
..........

However, I didn't realize you had to do everything within the *default* constructor of the WebPage derived class...oops!  I start to see this exception all over again:

wicket.markup.MarkupException : Unable to find component with id 'headerPanel' in......

Am I making this more complicated than it needs to be?  What is a better approach?

Thanks!






Reply via email to