Mapping wicket:id to component without changing Java code

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Mapping wicket:id to component without changing Java code

Alec Swan
Hello,

I would like to add credit card processing form to many different pages in
my application. However, I don't know which pages it will be added to and it
is up to the web designer to decide.

I would like to allow the web designer to be able to put <div
wicket:id="creditCardForm"/> anywhere in HTML. This would typically cause
Wicket to throw an error saying that a matching component was not added.

Is there a way to configure Wicket to somehow add an instance of
CreditCardForm class whenever it sees <div wicket:id="creditCardForm"/>?

Thanks,

Alec
Reply | Threaded
Open this post in threaded view
|

Re: Mapping wicket:id to component without changing Java code

Andrea Del Bene-2
Hi Alec,

I don't think Wicket has a configuration option that can help you. But
you can create a web page superclass that parses HTML and adds your form
if it finds tag <div wicket:id="creditCardForm"/>.
For example you can override onInitialize method and add something like
this:


MarkupParser markupParser = new MarkupParser(new XmlPullParser(), new
MarkupResourceStream(getMarkupStream().getResource()));
Markup markup = markupParser.parse();

for(int i = 0; i < markup.size(); i++) {
             if(markup.get(i) instanceof ComponentTag){
                 String markupId = (ComponentTag) markup.get(i);
                 //if markupid is equals to "creditCardForm" add form
             }
}



bye.

> Hello,
>
> I would like to add credit card processing form to many different pages in
> my application. However, I don't know which pages it will be added to and it
> is up to the web designer to decide.
>
> I would like to allow the web designer to be able to put<div
> wicket:id="creditCardForm"/>  anywhere in HTML. This would typically cause
> Wicket to throw an error saying that a matching component was not added.
>
> Is there a way to configure Wicket to somehow add an instance of
> CreditCardForm class whenever it sees<div wicket:id="creditCardForm"/>?
>
> Thanks,
>
> Alec
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Mapping wicket:id to component without changing Java code

msj121
You can add an empty label to replace the content if not adding the component. You can have a repeating list if you have lots of dynamic content, this way whatever you add to the list is added or you can just add an empty component.

It does seem odd to me that in your html you know whether to add the credit card div, but in Wicket you do not... that is certainly unclear to me.

Btw, I am building an e-commerce solution myself, are you using an opensource platform or building it yourself?

> Hello,
>
> I would like to add credit card processing form to many different pages in
> my application. However, I don't know which pages it will be added to and it
> is up to the web designer to decide.
>
> I would like to allow the web designer to be able to put<div
> wicket:id="creditCardForm"/>  anywhere in HTML. This would typically cause
> Wicket to throw an error saying that a matching component was not added.
>
> Is there a way to configure Wicket to somehow add an instance of
> CreditCardForm class whenever it sees<div wicket:id="creditCardForm"/>?
>
> Thanks,
>
> Alec
>
Reply | Threaded
Open this post in threaded view
|

Re: Mapping wicket:id to component without changing Java code

James Carman
On Tue, Feb 1, 2011 at 10:27 AM, msj121 <[hidden email]> wrote:
>
> You can add an empty label to replace the content if not adding the
> component.

Or, use EmptyPanel or a plain ole WebMarkupContainer?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Mapping wicket:id to component without changing Java code

Alec Swan
Thank you everybody for the clever ideas.

msj121, I just started building the credit card form and was planning to
just use Authorize.net APIs. This is not directly related to Wicket, so we
should take this discussion off this forum. Email me directly if you have
some thoughts or just wanted to bounce ideas off.

Thanks,

Alec

On Tue, Feb 1, 2011 at 8:50 AM, James Carman <[hidden email]>wrote:

> On Tue, Feb 1, 2011 at 10:27 AM, msj121 <[hidden email]> wrote:
> >
> > You can add an empty label to replace the content if not adding the
> > component.
>
> Or, use EmptyPanel or a plain ole WebMarkupContainer?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Mapping wicket:id to component without changing Java code

msj121
Not sure how to e-mail someone directly as e-mails are hidden.... But it's okay, I will probably look to implement an existing open source system with Wicket, I am just curious if anyone would want to work on building a specific open source idea for wicket either from scratch or properly building off a basic system....

If I build an e-commerce system from scratch I certainly wouldn't want to do it alone.... But I wish you luck with your system.

Matthew
Reply | Threaded
Open this post in threaded view
|

Re: Mapping wicket:id to component without changing Java code

martin.dilger
Hi,

some days ago, I experimented with exactly the same usecase (letting webdesigners place components on a Wicket Page), i wrote a small BlogEntry (unfortunately in German, but maybe Google could translate).

http://splitshade.wordpress.com/2011/01/27/wicket-markup-komponenten-braucht-man-das/

Bye

Martin
Reply | Threaded
Open this post in threaded view
|

Re: Mapping wicket:id to component without changing Java code

jeremy@wickettraining.com
In reply to this post by Alec Swan
create your own component resolver

Jeremy Thomerson
http://wickettraining.com
-- sent from my "smart" phone, so please excuse spelling, formatting, or
compiler errors

On Jan 31, 2011 7:52 PM, "Alec Swan" <[hidden email]> wrote:

Hello,

I would like to add credit card processing form to many different pages in
my application. However, I don't know which pages it will be added to and it
is up to the web designer to decide.

I would like to allow the web designer to be able to put <div
wicket:id="creditCardForm"/> anywhere in HTML. This would typically cause
Wicket to throw an error saying that a matching component was not added.

Is there a way to configure Wicket to somehow add an instance of
CreditCardForm class whenever it sees <div wicket:id="creditCardForm"/>?

Thanks,

Alec