RE: What does this syntax say?

2011-07-29 Thread Wilhelmsen Tor Iver
 public W IWrapModelW wrapOnInheritance(Component component,ClassW
 type)

The ClassW parameter is only needed if you intend to do new W(); or the 
like in the method (the Class is then something the compiler can grab hold of 
for calling the constructor). For just passing the type parameter to other 
generic classes it is not needed. The compiler sees the context (i.e. the 
left-hand side of an assignment) and if it cannot determine the type it will 
say needs a cast as a warning, but the code will compile since it's all 
Object anyway. 

- Tor Iver


RE: getInput and getDefaultModelObject and validation

2011-07-29 Thread Wilhelmsen Tor Iver
 If I am using some form validator, I notice that getDefaultModelObject
 does not have the value from the getInput.  I am assume this
 intentional.  Is there a way to force wicket to update the modelObject?

Yes, form component models are not updated until they pass validation, that is 
very intentional. :)

(E.g. if you have a Date text field and someone types beer, what would you 
expect to be written to the model?)

 How and when does the modelobject get updated.
 
When all validation succeeds and it progresses into a submit.

 But if I weren't using ajax, is there a way to force wicket to update
 the modelObject.

That will happen automatically after validation passes. Validation should 
ideally only check inputs and give any errors.

- Tor Iver

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



show modal window without clicking on ajaxLink

2011-07-29 Thread Mathilde Pellerin
Hi all,

I have a page with an AjaxLink which shows a modal window. This modal window
contains a form and when we submit the form, modal window disappear, my page
is reloaded and a second ajaxLink is created. When we click on this second
ajaxLink, another modal window appears.
This part works well, but now, I want that the second modal window appears
after submitting the first form (and so without clicking on the second ajax
Link).

I try this on my form onSubmit method :
protected void onSubmit(AjaxRequestTarget target, Form? form) {
//[...] some form processing

membreCourant = serviceMembre.enregistrerReponses(membreCourant,
questionnaireCourant);
SessionE4N.get().setMembre(membreCourant);
//reload the page, so first modal window disappears and second ajax link
is created
setResponsePage(QuestionnairesPage.class, new PageParameters(p=3));

//on affiche le module correspondant au questionnaire qu'on vient de
remplir
qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
qPage.getModalModule().setTitle(Module
+questionnaireCourant.getTitre());
qPage.getModalModule().show(target);
}

qPage is initialize on modal window constructor:
public QuestionnaireContentPanel(String id, QuestionnairesPage
questionnairesPage){
super(id);
this.qPage = questionnairesPage;
FormVoid qForm = creationFormulaireQuestionnaire();
add(qForm);
}

but it doesn't work : second modal window is not shown.
What am I doing wrong?


This code in my page creates modal windows :
modalQuestionnaire = new ModalWindowE4N(modalQuestionnaire,
);
questionnaireContentPanel = new
QuestionnaireContentPanel(modalQuestionnaire.getContentId(), this);
modalQuestionnaire.setContent(questionnaireContentPanel);
modalQuestionnaire.setInitialWidth(800);
add(modalQuestionnaire);

modalModule =  new ModalWindowE4N(modalModule, );
moduleContentPanel = new
ModuleContentPanel(modalModule.getContentId());
modalModule.setContent(moduleContentPanel);
modalModule.setInitialWidth(800);
add(modalModule);

this code create ajaxLink for second modal windows (code for first modal
window is similar):
//Repeatingview pour la liste des modules
RepeatingView listeModules = new RepeatingView(listeModule);
add(listeModules);

ListListeQuestionnaire questionnaires =
membre.getListeQuestionnaires();
for (ListeQuestionnaire questionnaire : questionnaires) {
WebMarkupContainer item = new
WebMarkupContainer(listeModules.newChildId());
listeModules.add(item);

Questionnaire q = questionnaire.getQuestionnaire();
item.add(new Label(titreModule, Module
+q.getTitre()));
item.add(new BoutonVisualiserModule(boutonModule,  new
ModelQuestionnaire(q)));
}

and BoutonVisualiserModule :
class BoutonVisualiserModule extends Panel
{
public BoutonVisualiserModule(String id, IModel? model) {
super(id, model);

//Ajout du lien qui affichera le module
AjaxLinkVoid showModule = new AjaxLinkVoid(visualiser) {
@Override
public void onClick(AjaxRequestTarget target) {
qCourant =
(Questionnaire)getParent().getDefaultModelObject();


target.appendJavascript(Wicket.Window.unloadConfirmation = false;);
moduleContentPanel.initialiserModule(qCourant);
modalModule.setTitle(Module +qCourant.getTitre());
modalModule.show(target);
}
};
add(showModule);
}
}


-- 
*Mathilde Pellerin*
Ingénieur en développement de logiciel

STATLIFE
tel : 01.42.11.64.88
mail : mathilde.pelle...@statlife.fr


Re: show modal window without clicking on ajaxLink

2011-07-29 Thread Sven Meier
Hi,

setResponsePage(QuestionnairesPage.class, new PageParameters(p=3));

you're leaving the current page before it can open the new modal window.

Try this instread:

firstPage.getModalModule().close(target); 

...

qPage.getModalModule().show(target); 

Hope this helps
Sven

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/show-modal-window-without-clicking-on-ajaxLink-tp3703364p3703409.html
Sent from the Users forum mailing list archive at Nabble.com.

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



RE: getInput and getDefaultModelObject and validation

2011-07-29 Thread Brown, Berlin [GCG-PFS]
I guess there are cases where you want to use an AbstractFormValidator
and run validation on a form before it is submitted and want to address
those fields before they are submitted.  It would be nice if the
modelobject were updated.

Let's say you have 100 textfields attached to a form, you want to
validate some of the fields, all at once (say using FormValidator
attached to the form),

Is there a way to force a modelobject update on each individual field
and then do my form validation.  (I guess the only way is through ajax
events on each field).

E.g.

Form.add(new TextField);
Form.add(new TextField);
Form.add(new TextField);
Form.add(new TextField);
Form.add(new TextField);

Form.add(new AbstractFormValidator() {
   onValidate() {
  if (textField1.getInput() == creditCard) {
  }
   }
});
...

With the code above, I have to do all of my form validation without my
desired type.

-Original Message-
From: Wilhelmsen Tor Iver [mailto:toriv...@arrive.no] 
Sent: Friday, July 29, 2011 3:20 AM
To: users@wicket.apache.org
Subject: RE: getInput and getDefaultModelObject and validation

 If I am using some form validator, I notice that getDefaultModelObject

 does not have the value from the getInput.  I am assume this 
 intentional.  Is there a way to force wicket to update the
modelObject?

Yes, form component models are not updated until they pass validation,
that is very intentional. :)

(E.g. if you have a Date text field and someone types beer, what would
you expect to be written to the model?)

 How and when does the modelobject get updated.
 
When all validation succeeds and it progresses into a submit.

 But if I weren't using ajax, is there a way to force wicket to update 
 the modelObject.

That will happen automatically after validation passes. Validation
should ideally only check inputs and give any errors.

- Tor Iver

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




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



Re: show modal window without clicking on ajaxLink

2011-07-29 Thread Andrea Del Bene

Hi Mathilde,

why not simply substitute modal window content instead of reloading page 
and creating a brand new modal window?
Your code doesn't work because setResponsePage create a new instance of 
QuestionnairesPage different from the one referenced by qPage variable.




Hi all,

I have a page with an AjaxLink which shows a modal window. This modal window
contains a form and when we submit the form, modal window disappear, my page
is reloaded and a second ajaxLink is created. When we click on this second
ajaxLink, another modal window appears.
This part works well, but now, I want that the second modal window appears
after submitting the first form (and so without clicking on the second ajax
Link).

I try this on my form onSubmit method :
protected void onSubmit(AjaxRequestTarget target, Form?  form) {
 //[...] some form processing

 membreCourant = serviceMembre.enregistrerReponses(membreCourant,
questionnaireCourant);
 SessionE4N.get().setMembre(membreCourant);
 //reload the page, so first modal window disappears and second ajax link
is created
 setResponsePage(QuestionnairesPage.class, new PageParameters(p=3));

 //on affiche le module correspondant au questionnaire qu'on vient de
remplir
 qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
 qPage.getModalModule().setTitle(Module
+questionnaireCourant.getTitre());
 qPage.getModalModule().show(target);
}

qPage is initialize on modal window constructor:
 public QuestionnaireContentPanel(String id, QuestionnairesPage
questionnairesPage){
 super(id);
 this.qPage = questionnairesPage;
 FormVoid  qForm = creationFormulaireQuestionnaire();
 add(qForm);
 }

but it doesn't work : second modal window is not shown.
What am I doing wrong?



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



RE: getInput and getDefaultModelObject and validation

2011-07-29 Thread Wilhelmsen Tor Iver
 Is there a way to force a modelobject update on each individual field
 and then do my form validation.

It seems you want to use getConvertedInput(). Going via the model to get the 
converted value is just a detour when you are in a validator. If you push data 
to the model and then decide it is invalid, then your model will have invalid 
data, and if that is acceptable, what role does the validator fill then? You 
might as well do your checks in onSubmit() at that point...

  if (textField1.getInput() == creditCard) {

You should be aware that this code will most likely fail. Look into equals().

- Tor Iver

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



Re: show modal window without clicking on ajaxLink

2011-07-29 Thread Mathilde Pellerin
Thanks a lot for your answer.
The solution of Sven Meier works well.

Sometimes I wonder why I always try complex solutions instead of simplest
one...


RE: getInput and getDefaultModelObject and validation

2011-07-29 Thread Brown, Berlin [GCG-PFS]
 then your model will have invalid data, and if that is acceptable,
what role does the validator fill then? You might as well do your checks
in onSubmit() at that point...

I guess it depends, I normally haven't had a need to validate every
individual component.  But I like having all of my model objects with
their values and then doing validation of those values/types before the
form is submitted.

getConvertedInput would work

what role does the backing object fill if you can't using them during
your validation.

I guess in some cases you want an override switch to allow the model
object to get updated with the input pre-validation.

...
As a hack, we normally just add ajaxbehaviors on the components and
their values get updated, then I can do form validation with all the
updated models.

-Original Message-
From: Wilhelmsen Tor Iver [mailto:toriv...@arrive.no] 
Sent: Friday, July 29, 2011 5:04 AM
To: users@wicket.apache.org
Subject: RE: getInput and getDefaultModelObject and validation

 Is there a way to force a modelobject update on each individual field 
 and then do my form validation.

It seems you want to use getConvertedInput(). Going via the model to get
the converted value is just a detour when you are in a validator. If you
push data to the model and then decide it is invalid, then your model
will have invalid data, and if that is acceptable, what role does the
validator fill then? You might as well do your checks in onSubmit() at
that point...

  if (textField1.getInput() == creditCard) {

You should be aware that this code will most likely fail. Look into
equals().

- Tor Iver

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




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



Re: show modal window without clicking on ajaxLink

2011-07-29 Thread Mathilde Pellerin
Well, I talked too fast.
In fact, with Sven's solution :

membreCourant =
serviceMembre.enregistrerReponses(membreCourant, questionnaireCourant);
SessionE4N.get().setMembre(membreCourant);
//setResponsePage(QuestionnairesPage.class, new
PageParameters(p=3));

qPage.getModalQuestionnaire().close(target);

//on affiche le module correspondant au questionnaire qu'on
vient de remplir

qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
qPage.getModalModule().setTitle(Module
+questionnaireCourant.getTitre());
qPage.getModalModule().show(target);

first modal window is closed, but the second is not really shown : in fact,
a modal window empty appears, but it has the first modal window title. (and
second modal window shouldn't be empty thanks to method initialiserModule)
I don't understand what happen, so if you have an idea, let me know...


2011/7/29 Mathilde Pellerin mathilde.pelle...@statlife.fr

 Thanks a lot for your answer.
 The solution of Sven Meier works well.

 Sometimes I wonder why I always try complex solutions instead of simplest
 one...




-- 
*Mathilde Pellerin*
Ingénieur en développement de logiciel

STATLIFE
tel : 01.42.11.64.88
mail : mathilde.pelle...@statlife.fr


Re: Ajax broken in IE 8

2011-07-29 Thread Martin Grigorov
1.4.17 is in use by many people and you're the only one having this problem.

1.5.x and 1.4.x are the same related to WICKET-3887.

AjaxLink/AjaxFallbackLink cannot do POST request unless you override
parts of them.

On Fri, Jul 29, 2011 at 7:54 AM, T P D li...@diffenbach.org wrote:
 Wicket 1.4.9's Ajax doesn't work in Internet Explorer; in particular,
 AjaxFallbackButtons fall back to non-Ajax POSTs, and the Wicket Debug
 window is never seen.

 In 1.4.17, Ajax is still broken, but the fallback never happens, because
 Ajax sort-of works: the the Wicket Debug window doe show up, and when the
 AjaxFallbackButton is clicked, a attempt is made to to XMLHTTP, but fails
 with Automation server can't create object.

 This looks like the same bug as reported in
 https://issues.apache.org/jira/browse/WICKET-3887 and
 https://issues.apache.org/jira/browse/WICKET-1432. It's apparently fixed in
 1.5, but while bug 3887 is claimed to be fixed in 1.4.18, the latest
 snapshot exhibits the same behavior as 1.4.17.

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





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

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



Re: AjaxFormComponentUpdatingBehavior target.addComponent(component) causes to lose focus

2011-07-29 Thread Jack Berg
It seems, that cause was, that I was adding all the components to the
AjaxRequestTarget in my AjaxRequestTarget.IListener. Is it a bug, that it
does not return focus to the replaced component?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-target-addComponent-component-causes-to-lose-focus-tp3700530p3703624.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: show modal window without clicking on ajaxLink

2011-07-29 Thread Andrea Del Bene

Try to use just one modal window and switch content panels. I.e:

-Create modal window with questionnaireContentPanel as initial content:

modalQuestionnaireModule = new 
ModalWindowE4N(modalQuestionnaireModule,);
questionnaireContentPanel = new 
QuestionnaireContentPanel(modalQuestionnaireModule.getContentId(), this);


modalQuestionnaireModule.setContent(questionnaireContentPanel);
modalQuestionnaireModule.setInitialWidth(800);

add(modalQuestionnaireModule);


-Show modal window



-After submit substitute window content with ModuleContentPanel:


protected void onSubmit(AjaxRequestTarget target, Form? form) {
//[...] some form processing

membreCourant = serviceMembre.enregistrerReponses(membreCourant,
questionnaireCourant);
SessionE4N.get().setMembre(membreCourant);

//substitute window content
Panel newContent = new 
ModuleContentPanel(modalQuestionnaireModule.getContentId(), this);

modalQuestionnaireModule.setContent(newContent);

//re-render window itself.
target.addComponent(modalQuestionnaireModule);




Well, I talked too fast.
In fact, with Sven's solution :

 membreCourant =
serviceMembre.enregistrerReponses(membreCourant, questionnaireCourant);
 SessionE4N.get().setMembre(membreCourant);
 //setResponsePage(QuestionnairesPage.class, new
PageParameters(p=3));

 qPage.getModalQuestionnaire().close(target);

 //on affiche le module correspondant au questionnaire qu'on
vient de remplir

qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
 qPage.getModalModule().setTitle(Module
+questionnaireCourant.getTitre());
 qPage.getModalModule().show(target);

first modal window is closed, but the second is not really shown : in fact,
a modal window empty appears, but it has the first modal window title. (and
second modal window shouldn't be empty thanks to method initialiserModule)
I don't understand what happen, so if you have an idea, let me know...


2011/7/29 Mathilde Pellerinmathilde.pelle...@statlife.fr


Thanks a lot for your answer.
The solution of Sven Meier works well.

Sometimes I wonder why I always try complex solutions instead of simplest
one...







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



Re: show modal window without clicking on ajaxLink

2011-07-29 Thread Mathilde Pellerin
I tried your solution Andrea :
- just one modal window :
modalWindow = new ModalWindowE4N(modalQuestionnaire, );
questionnaireContentPanel = new
QuestionnaireContentPanel(modalWindow.getContentId(), this);
modalWindow.setContent(questionnaireContentPanel);
modalWindow.setInitialWidth(800);
add(modalWindow);

- after submit, substitute window content with ModuleContentPanel :
membreCourant =
serviceMembre.enregistrerReponses(membreCourant, questionnaireCourant);
SessionE4N.get().setMembre(membreCourant);
//qPage.getModalWindow().close(target);
ModuleContentPanel moduleContentPanel = new
ModuleContentPanel(qPage.getModalWindow().getContentId());
moduleContentPanel.initialiserModule(questionnaireCourant);
qPage.getModalWindow().setTitle(Module
+questionnaireCourant.getTitre());
qPage.getModalWindow().setContent(moduleContentPanel);

target.addComponent(qPage.getModalWindow());
//qPage.getModalWindow().show(target);

but modal window is not re-render, so it content is not changed...
maybe target.addComponent() is not sufficient?

so I tried also with qPage.getModalWindow().close before changes and
qPage.getModalWindow().show() after changes (with or without
target.addComponent) : in these cases, we can see modal window change a
second and then render with first content...

what am I doing wrong?


Re: Scala DSL for Wicket

2011-07-29 Thread Martin Grigorov
Bruno,

Yet another idea for the dsl:

def ldm[R, ID](id: ID = null, f: (ID) = R) = {new
LoadableDetachableModel(id) { override def load() : R = { f(id); } } }

P.S. Not tested.

On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges bruno.bor...@gmail.com wrote:
 Just wanted to share my experience playing a little more with Scala and
 Wicket A few minutes ago I got this excelent code:

 I know it is too simple, and it can be accomplished as well in Java with
 static imports. But still, for my project it's being great (and cool) to do
 such things.

     object btnEditar extends Button(btnEditar) {
       override def onSubmit() = {
 -        /* show fields */
 -        camposForm.setVisibilityAllowed(true)
 -        btnSalvar.setVisibilityAllowed(true)
 -        cancelar.setVisibilityAllowed(true)
 -
 -        /* hide them */
 -        camposTela.setVisibilityAllowed(false)
 -        btnEditar.setVisibilityAllowed(false)
 +        show(camposForm, btnSalvar, cancelar)
 +        hide(camposTela, btnEditar)
       }
     }
     add(btnEditar)

 Methods show/hide are imported as import code.DSLWicket._



 *Bruno Borges*
 www.brunoborges.com.br
 +55 21 76727099



 On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges bruno.bor...@gmail.comwrote:

 Thanks Martin,

 There was only a small little problem in your code. The correct syntax is:

 def label[T](id: String, model: IModel[T] = null): Label = { val label
 = new Label(id, model); add(label); label }

 The suggestions were updated on Gist.

 *Bruno Borges*
 www.brunoborges.com.br
 +55 21 76727099



 On Wed, Jul 27, 2011 at 3:55 PM, Martin Grigorov mgrigo...@apache.orgwrote:

 Idea for simplification: use named parameters.
 For example
 def label[T](id: String, model: IModel[T]): Label = { val label = new
 Label(id, model); add(label); label }
 would become
 def label[T](id: String, model = _ : IModel[T]): Label = { val label =
 new Label(id, model); add(label); label }

 this way you'll have just one declaration of label function which will
 handle the current three

 additionally you may add a pimp:
 implicit def ser2model[S : Serializable](ser: S): IModel[S] =
 Model.of(ser)

 now even when you pass String as second param to label() it will be
 converted to IModel

 On Wed, Jul 27, 2011 at 9:11 PM, Martin Grigorov mgrigo...@apache.org
 wrote:
  Take a look at scala.swing.* sources.
 
  On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges bruno.bor...@gmail.com
 wrote:
  Can some Scala expert help me to make this DSL available as PML (pimp
 my
  library)?
 
  I've tried to code it that way but things didn't quite worked out the
 way
  they should.
 
  The reason is that for every Wicket object I create, I must extend the
 trait
  DSLWicket
 
 
 
  *Bruno Borges*
  www.brunoborges.com.br
  +55 21 76727099
 
 
 
  On Wed, Jul 27, 2011 at 2:30 PM, Bruno Borges bruno.bor...@gmail.com
 wrote:
 
  Not really.
 
  The method onSubmit() of button is void, as well onClick(), so there's
 no
  need for the function be passed as () = Unit or anything else.
 
  I made a few changes to it and updated on Gist.
 
  I've also uploaded a page that uses this DSL at
  https://gist.github.com/1109919
 
  Take a look
 
  *Bruno Borges*
  www.brunoborges.com.br
  +55 21 76727099
 
 
 
  On Wed, Jul 27, 2011 at 2:22 PM, Scott Swank scott.sw...@gmail.com
 wrote:
 
  I think you do want Unit, which as I understand it is closest
  equivalent to void in Scala.
 
  http://www.scala-lang.org/api/current/scala/Unit.html
 
  Scott
 
  On Wed, Jul 27, 2011 at 10:14 AM, Bruno Borges 
 bruno.bor...@gmail.com
  wrote:
   No, the function must return void, not another function (unit).
  
   But there's also the option of () = Nothing. Which one should I
 use for
   this case?
  
   *Bruno Borges*
   www.brunoborges.com.br
   +55 21 76727099
  
  
  
   On Wed, Jul 27, 2011 at 12:54 PM, Martin Grigorov 
 mgrigo...@apache.org
  wrote:
  
    def button(id: String, submit: () = Void): Button = {
  
   it should be () = Unit, no ?
  
   On Wed, Jul 27, 2011 at 6:51 PM, Martin Grigorov 
 mgrigo...@apache.org
  
   wrote:
Adding some usage examples at the bottom will help us evaluate
 it.
   
Why not add type to
def textField(id: String): TextField[_] = { val field = new
TextField(id); add(field); field }
to become
def textField[T](id: String): TextField[T] = { val field = new
TextField[T](id); add(field); field }
   
usage: textField[Int](someId)
   
with using implicit Manifest for T you can also can
 automatically set
the type: field.setType(m.erasure)
   
On Wed, Jul 27, 2011 at 6:26 PM, Bruno Borges 
  bruno.bor...@gmail.com
   wrote:
I've been playing with Wicket and Scala and I thought this
 could be
   added to
the wicket-scala project at WicketStuff.
   
What do you guys think?
   
https://gist.github.com/1109603
   
   
*Bruno Borges*
www.brunoborges.com.br
+55 21 76727099
   
   
   
   
--
Martin Grigorov
jWeekend

Re: Repeating form on a page

2011-07-29 Thread heikki
hello,

despite searching around I haven't found a good working example/explanation
of how to create a page where a form is repeated for each element in a
collection. (I found some info on using repeaters inside forms, but that is
a reverse situation).

Earlier in this thread there's the advice to use RefreshingView instead of
ListView. Is this good advice? What is the difference between them in this
scenario where forms should be repeated?

I tried doing it as below, but it causes a runtime exception. Can anyone
point out what I'm doing wrong and how it should be done?

The exception I'm getting is

Last cause: Unable to find component with id 'aForm' in [ListItem [Component
id = 0]]
Expected: 'a-list:0.aForm'.
Found with similar names: 'a-list:aForm'

The code is

div wicket:id=a-list
form wicket:id=aForm
input wicket:id=myproperty type=text/
div
input wicket:id=save type=submit value=Save/
input wicket:id=remove type=submit value=Remove/
/div
/form
/div

private ListView aList = new ListView(a-list, aDAO.retrieveAll()) {
@Override
protected void populateItem(ListItem item) {
final A a = (A) item.getModelObject();
add(new AForm(aForm,
new CompoundPropertyModel(new
LoadableDetachableModel() {
@Override
protected Object load() {
return a;
}
})
));
}};
 private class AForm extends Form {
public AForm(String id, IModel m) {
super(id, m);
TextField myProperty= new TextField(myproperty);
add(myProperty);
add(new Button(save) {
public void onSubmit() {
A selected = (A) getForm().getModelObject();
ADAO.save(selected);
setResponsePage(APage.class);
}
});
add(
new Button(remove) {
@Override
public void onSubmit() {
A selected = (A) getForm().getModelObject();
ADAO.delete(selected);
setResponsePage(APage.class);
}
});
}
}

thanks in advance for your reply,
kind regards
Heikki Doeleman

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Repeating-form-on-a-page-tp2002098p3703919.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: show modal window without clicking on ajaxLink

2011-07-29 Thread Andrea Del Bene
Sorry, you are right. Under wicket 1.5 works calling replaceWith on old 
content. In your code should be something like :


moduleContentPanel = 
questionnaireContentPanel.replaceWith(moduleContentPanel);

target.addComponent(moduleContentPanel);


I didn't tested it with 1.4.x version.




I tried your solution Andrea :
- just one modal window :s
 modalWindow = new ModalWindowE4N(modalQuestionnaire, );
 questionnaireContentPanel = new
QuestionnaireContentPanel(modalWindow.getContentId(), this);
 modalWindow.setContent(questionnaireContentPanel);
 modalWindow.setInitialWidth(800);
 add(modalWindow);

- after submit, substitute window content with ModuleContentPanel :
 membreCourant =
serviceMembre.enregistrerReponses(membreCourant, questionnaireCourant);
 SessionE4N.get().setMembre(membreCourant);
 //qPage.getModalWindow().close(target);
 ModuleContentPanel moduleContentPanel = new
ModuleContentPanel(qPage.getModalWindow().getContentId());
 moduleContentPanel.initialiserModule(questionnaireCourant);
 qPage.getModalWindow().setTitle(Module
+questionnaireCourant.getTitre());
 qPage.getModalWindow().setContent(moduleContentPanel);

 target.addComponent(qPage.getModalWindow());
 //qPage.getModalWindow().show(target);

but modal window is not re-render, so it content is not changed...
maybe target.addComponent() is not sufficient?

so I tried also with qPage.getModalWindow().close before changes and
qPage.getModalWindow().show() after changes (with or without
target.addComponent) : in these cases, we can see modal window change a
second and then render with first content...

what am I doing wrong?




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



Re: wicketstuff tinymce development

2011-07-29 Thread jbrookover

Michal Letynski wrote:
 
 Ok i solved the problem. I used wrong version (1.4.17.3 - its buggy). I
 get exceptions:
 java.lang.StringIndexOutOfBoundsException: String index out of range: -1
  at java.lang.String.substring(String.java:1937)
  at
 wicket.contrib.tinymce.settings.TinyMCESettings.lazyLoadTinyMCEResource(TinyMCESettings.java:971)
  at 
 wicket.contrib.tinymce.TinyMceBehavior.renderHead(TinyMceBehavior.java:60)
 
 And looking and java docs ( TODO: This has not been extensively 
 tested.) it still under development.
 

For TinyMCE to work properly with AJAX, it must be loaded on the page prior
to the Ajax call that generates the editor.  This is a flaw with TinyMCE
itself, not the wicket component.

Up until version 1.4.17.2, you needed to render the TinyMCE javascript
resource with the Page (or some other non-Ajax generated component) and then
individual components can use TinyMCEBehavior on an Ajax rendered text area. 
This is described in the JavaDoc for lazyLoadTinyMCEResource().

lazyLoadTinyMCEResource() was my attempt to get around this requirement and
load the javascript via Ajax.  I suspect the problem is not with the
technique but with the URL manipulation.  Feel free to contribute a bug fix
and/or ignore the lazyLoadTinyMCEResource() function.  However, it should be
considered beta and is completely optional.  You can still use the old
method.

Hope that helps!  I still recommend using 1.4.17.3 as it has an up-to-date
version of TinyMCE and several other improvements.

Jake

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wicketstuff-tinymce-development-tp3698059p3704257.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Ajax broken in IE 8

2011-07-29 Thread T P D
OK, so since I'm having this problem and no one else is -- what am I 
doing wrong?


And why is it working in Firefox? In Firefox, with javascript disabled, 
I get a normal POST; with javascript enabled, I get ajax.


In IE 8, using Wicket 1.4.9, even with javascript enabled, I get a POST 
(the fallback part of the AjaxFallbackButton), but with Wicket 1.4.17, 
I have broken ajax (because of the transport), but I also don't get a 
fallback POST.


I'm thrilled if the fault lies with me, because that's presumably easier 
to fix. But what am I (not) doing that breaks this?


On 7/29/2011 6:11 AM, Martin Grigorov wrote:

1.4.17 is in use by many people and you're the only one having this problem.

1.5.x and 1.4.x are the same related to WICKET-3887.

AjaxLink/AjaxFallbackLink cannot do POST request unless you override
parts of them.

On Fri, Jul 29, 2011 at 7:54 AM, T P Dli...@diffenbach.org  wrote:

Wicket 1.4.9's Ajax doesn't work in Internet Explorer; in particular,
AjaxFallbackButtons fall back to non-Ajax POSTs, and the Wicket Debug
window is never seen.

In 1.4.17, Ajax is still broken, but the fallback never happens, because
Ajax sort-of works: the the Wicket Debug window doe show up, and when the
AjaxFallbackButton is clicked, a attempt is made to to XMLHTTP, but fails
with Automation server can't create object.

This looks like the same bug as reported in
https://issues.apache.org/jira/browse/WICKET-3887 and
https://issues.apache.org/jira/browse/WICKET-1432. It's apparently fixed in
1.5, but while bug 3887 is claimed to be fixed in 1.4.18, the latest
snapshot exhibits the same behavior as 1.4.17.

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








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



Re: How to Integrate Wicket with Apache POI

2011-07-29 Thread eugenebalt
It's very easy.

1) In your HTML:

# Export to Spreadsheet 

2) In your Java:

add(new DownloadLink(link, generateExcelFile());


The DownloadLink is a provided Wicket class. Note that generateExcelFile()
must return a File object. If the file already exists, you just read it. If
you need to create a spreadsheet in POI, I recommend something like this
utility method:

public void File generateExcelFile() {

   FileOutputStream fos = new FileOutputStream(new File(report.xls));
   HSSFWorkbook wb = new HSSFWorkbook();
   
   //...

   wb.write(fos);

   fos.close();

}

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-Integrate-Wicket-with-Apache-POI-tp3704158p3704508.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: How to Integrate Wicket with Apache POI

2011-07-29 Thread eugenebalt
Sorry; in the previous post, the HTML got rendered.

I meant to write,

1) In HTML:

a wicket:id=link href=#   (just create the standard HTML link)

2) In Java, use

add(new DownloadLink(link, file));



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-Integrate-Wicket-with-Apache-POI-tp3704158p3704512.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Repeating form on a page

2011-07-29 Thread Sven Meier

Hi,

it really doesn't matter which repeater, but ListView is probably the 
most easy to use.


protected void populateItem(ListItem item) {
add(new AForm(...);
}

Typical error each of us has done wrong when using repeaters for the 
first time. It has to be:


item.add(new AForm(...);

Hope this helps
Sven

On 07/29/2011 02:50 PM, heikki wrote:

hello,

despite searching around I haven't found a good working example/explanation
of how to create a page where a form is repeated for each element in a
collection. (I found some info on using repeaters inside forms, but that is
a reverse situation).

Earlier in this thread there's the advice to use RefreshingView instead of
ListView. Is this good advice? What is the difference between them in this
scenario where forms should be repeated?

I tried doing it as below, but it causes a runtime exception. Can anyone
point out what I'm doing wrong and how it should be done?

The exception I'm getting is

Last cause: Unable to find component with id 'aForm' in [ListItem [Component
id = 0]]
Expected: 'a-list:0.aForm'.
Found with similar names: 'a-list:aForm'

The code is

 div wicket:id=a-list
 form wicket:id=aForm
 input wicket:id=myproperty type=text/
 div
 input wicket:id=save type=submit value=Save/
 input wicket:id=remove type=submit value=Remove/
 /div
 /form
 /div

 private ListView aList = new ListView(a-list, aDAO.retrieveAll()) {
 @Override
 protected void populateItem(ListItem item) {
 final A a = (A) item.getModelObject();
 add(new AForm(aForm,
 new CompoundPropertyModel(new
LoadableDetachableModel() {
 @Override
 protected Object load() {
 return a;
 }
 })
 ));
 }};
  private class AForm extends Form {
 public AForm(String id, IModel m) {
 super(id, m);
 TextField myProperty= new TextField(myproperty);
 add(myProperty);
 add(new Button(save) {
 public void onSubmit() {
 A selected = (A) getForm().getModelObject();
 ADAO.save(selected);
 setResponsePage(APage.class);
 }
 });
 add(
 new Button(remove) {
 @Override
 public void onSubmit() {
 A selected = (A) getForm().getModelObject();
 ADAO.delete(selected);
 setResponsePage(APage.class);
 }
 });
 }
 }

thanks in advance for your reply,
kind regards
Heikki Doeleman

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Repeating-form-on-a-page-tp2002098p3703919.html
Sent from the Users forum mailing list archive at Nabble.com.

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




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



Re: Ajax broken in IE 8

2011-07-29 Thread Dan Retzlaff
I'll help you test it if you boil it down to a quickstart application you
can share.

On Fri, Jul 29, 2011 at 8:12 AM, T P D li...@diffenbach.org wrote:

 OK, so since I'm having this problem and no one else is -- what am I doing
 wrong?

 And why is it working in Firefox? In Firefox, with javascript disabled, I
 get a normal POST; with javascript enabled, I get ajax.

 In IE 8, using Wicket 1.4.9, even with javascript enabled, I get a POST
 (the fallback part of the AjaxFallbackButton), but with Wicket 1.4.17, I
 have broken ajax (because of the transport), but I also don't get a fallback
 POST.

 I'm thrilled if the fault lies with me, because that's presumably easier to
 fix. But what am I (not) doing that breaks this?


 On 7/29/2011 6:11 AM, Martin Grigorov wrote:

 1.4.17 is in use by many people and you're the only one having this
 problem.

 1.5.x and 1.4.x are the same related to WICKET-3887.

 AjaxLink/AjaxFallbackLink cannot do POST request unless you override
 parts of them.

 On Fri, Jul 29, 2011 at 7:54 AM, T P Dli...@diffenbach.org  wrote:

 Wicket 1.4.9's Ajax doesn't work in Internet Explorer; in particular,
 AjaxFallbackButtons fall back to non-Ajax POSTs, and the Wicket Debug
 window is never seen.

 In 1.4.17, Ajax is still broken, but the fallback never happens, because
 Ajax sort-of works: the the Wicket Debug window doe show up, and when
 the
 AjaxFallbackButton is clicked, a attempt is made to to XMLHTTP, but fails
 with Automation server can't create object.

 This looks like the same bug as reported in
 https://issues.apache.org/**jira/browse/WICKET-3887https://issues.apache.org/jira/browse/WICKET-3887and
 https://issues.apache.org/**jira/browse/WICKET-1432https://issues.apache.org/jira/browse/WICKET-1432.
 It's apparently fixed in
 1.5, but while bug 3887 is claimed to be fixed in 1.4.18, the latest
 snapshot exhibits the same behavior as 1.4.17.

 --**--**
 -
 To unsubscribe, e-mail: 
 users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org






 --**--**-
 To unsubscribe, e-mail: 
 users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Advanced Mounting Markup Location

2011-07-29 Thread Arjun Dhar
When Locating the Markup for a Page, I want to know the corresponding class
(associated with the page/markup).
Currently Im directing Wicket to my Custom Markup location with the
following code in Application:

...
final IResourceStreamLocator defaultLocator =
super.getResourceSettings().getResourceStreamLocator();
return new ResourceStreamLocator(){
@Override
public IResourceStream locate(final Class? clazz, final String
path) {
   ...
   //Figure alternate path by reading path
   
   //if valid URL not found use the defaultLocator
   ...
}
...


I want to get the associated Component class. I know the String path
represents the ClassPath, but its still a String and contains Locale Junk 
an extension with it. 
Is there someway I can get Class? directly so I don't have to do String
manipulations?


Another thing I want is, when the dynamicPage (which --extends--
TemplatePage --extends--  WebPage) appears it knows its associated
Template DataStructure details.
TemplatePage - Wicket Component
Template - Data Structure

TemplatePage --- Template

When Mounting, on init() in Application:
application.mount(new QueryStringUrlCodingStrategy(pagePath, [Templace
Class] ));

During the mount itself, is there anyway for me to associate/pass models to
the pages which will be constructed?
Wicket uses no-arg Contstructors for WebPage, but what if I want to pass a
WebPage contexutal info specific to the Page while mounting? (Can i do
this?) -- I believe this would be efficient


-
Software documentation is like sex: when it is good, it is very, very good; and 
when it is bad, it is still better than nothing!
--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Advanced-Mounting-Markup-Location-tp3705032p3705032.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: resource problem..

2011-07-29 Thread mlabs
can you elaborate on that quick solution ?  i'm getting errors about not
finding the wicket:id .. the stylesheet link was in the HEAD section .. do I
need to move that? if not, how do I add the link on the java side? 
TIA

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/resource-problem-tp3697765p3705048.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Scala DSL for Wicket

2011-07-29 Thread Bruno Borges
I thought about this yesterday but maybe overloading the method is better.

Because this way the function must have to be passed as of expecting an id
argument, even if the id argument for ldm() is optional.

I just haven't added yet because of lack of usecase. :-)

But thanks!!

This DSL is saving me a lot of coding, even if is not actually a DSL, but a
way to go. :-)

*Bruno Borges*
www.brunoborges.com.br
+55 21 76727099



On Fri, Jul 29, 2011 at 9:44 AM, Martin Grigorov mgrigo...@apache.orgwrote:

 Bruno,

 Yet another idea for the dsl:

 def ldm[R, ID](id: ID = null, f: (ID) = R) = {new
 LoadableDetachableModel(id) { override def load() : R = { f(id); } } }

 P.S. Not tested.

 On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges bruno.bor...@gmail.com
 wrote:
  Just wanted to share my experience playing a little more with Scala and
  Wicket A few minutes ago I got this excelent code:
 
  I know it is too simple, and it can be accomplished as well in Java with
  static imports. But still, for my project it's being great (and cool) to
 do
  such things.
 
  object btnEditar extends Button(btnEditar) {
override def onSubmit() = {
  -/* show fields */
  -camposForm.setVisibilityAllowed(true)
  -btnSalvar.setVisibilityAllowed(true)
  -cancelar.setVisibilityAllowed(true)
  -
  -/* hide them */
  -camposTela.setVisibilityAllowed(false)
  -btnEditar.setVisibilityAllowed(false)
  +show(camposForm, btnSalvar, cancelar)
  +hide(camposTela, btnEditar)
}
  }
  add(btnEditar)
 
  Methods show/hide are imported as import code.DSLWicket._
 
 
 
  *Bruno Borges*
  www.brunoborges.com.br
  +55 21 76727099
 
 
 
  On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges bruno.bor...@gmail.com
 wrote:
 
  Thanks Martin,
 
  There was only a small little problem in your code. The correct syntax
 is:
 
  def label[T](id: String, model: IModel[T] = null): Label = { val label
  = new Label(id, model); add(label); label }
 
  The suggestions were updated on Gist.
 
  *Bruno Borges*
  www.brunoborges.com.br
  +55 21 76727099
 
 
 
  On Wed, Jul 27, 2011 at 3:55 PM, Martin Grigorov mgrigo...@apache.org
 wrote:
 
  Idea for simplification: use named parameters.
  For example
  def label[T](id: String, model: IModel[T]): Label = { val label = new
  Label(id, model); add(label); label }
  would become
  def label[T](id: String, model = _ : IModel[T]): Label = { val label =
  new Label(id, model); add(label); label }
 
  this way you'll have just one declaration of label function which will
  handle the current three
 
  additionally you may add a pimp:
  implicit def ser2model[S : Serializable](ser: S): IModel[S] =
  Model.of(ser)
 
  now even when you pass String as second param to label() it will be
  converted to IModel
 
  On Wed, Jul 27, 2011 at 9:11 PM, Martin Grigorov mgrigo...@apache.org
 
  wrote:
   Take a look at scala.swing.* sources.
  
   On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges 
 bruno.bor...@gmail.com
  wrote:
   Can some Scala expert help me to make this DSL available as PML
 (pimp
  my
   library)?
  
   I've tried to code it that way but things didn't quite worked out
 the
  way
   they should.
  
   The reason is that for every Wicket object I create, I must extend
 the
  trait
   DSLWicket
  
  
  
   *Bruno Borges*
   www.brunoborges.com.br
   +55 21 76727099
  
  
  
   On Wed, Jul 27, 2011 at 2:30 PM, Bruno Borges 
 bruno.bor...@gmail.com
  wrote:
  
   Not really.
  
   The method onSubmit() of button is void, as well onClick(), so
 there's
  no
   need for the function be passed as () = Unit or anything else.
  
   I made a few changes to it and updated on Gist.
  
   I've also uploaded a page that uses this DSL at
   https://gist.github.com/1109919
  
   Take a look
  
   *Bruno Borges*
   www.brunoborges.com.br
   +55 21 76727099
  
  
  
   On Wed, Jul 27, 2011 at 2:22 PM, Scott Swank 
 scott.sw...@gmail.com
  wrote:
  
   I think you do want Unit, which as I understand it is closest
   equivalent to void in Scala.
  
   http://www.scala-lang.org/api/current/scala/Unit.html
  
   Scott
  
   On Wed, Jul 27, 2011 at 10:14 AM, Bruno Borges 
  bruno.bor...@gmail.com
   wrote:
No, the function must return void, not another function (unit).
   
But there's also the option of () = Nothing. Which one should I
  use for
this case?
   
*Bruno Borges*
www.brunoborges.com.br
+55 21 76727099
   
   
   
On Wed, Jul 27, 2011 at 12:54 PM, Martin Grigorov 
  mgrigo...@apache.org
   wrote:
   
 def button(id: String, submit: () = Void): Button = {
   
it should be () = Unit, no ?
   
On Wed, Jul 27, 2011 at 6:51 PM, Martin Grigorov 
  mgrigo...@apache.org
   
wrote:
 Adding some usage examples at the bottom will help us
 evaluate
  it.

 Why not add type to
 def textField(id: String): TextField[_] = { val field = new
 TextField(id); add(field); field }
 to become
 

Manually Rendering a DataGridView

2011-07-29 Thread Matt Schmidt
Is there any way to access the HTML of each cell that would be rendered in a
DataGridView without adding it to the page and actually rendering it?

Ultimately, I am trying to add all of the inner HTML of the cells of the
DataGridView to a JavaScript array.


Re: Scala DSL for Wicket

2011-07-29 Thread Ben Tilford
For LDM

class Ldm[T](provider:()= T) extends LoadableDetachable... {
  def load():T {
provider()
  }
}

object Ldm {
  def apply(provider:()=T) = new Ldm[T](provider)
}

could be used as

...
val id = 1
val model = Ldm(()={dao.get(id)})

or

val id = 1
def provider = dao.get(id)
val model = Ldm(provider)


On Fri, Jul 29, 2011 at 6:44 AM, Martin Grigorov mgrigo...@apache.orgwrote:

 Bruno,

 Yet another idea for the dsl:

 def ldm[R, ID](id: ID = null, f: (ID) = R) = {new
 LoadableDetachableModel(id) { override def load() : R = { f(id); } } }

 P.S. Not tested.

 On Thu, Jul 28, 2011 at 9:07 AM, Bruno Borges bruno.bor...@gmail.com
 wrote:
  Just wanted to share my experience playing a little more with Scala and
  Wicket A few minutes ago I got this excelent code:
 
  I know it is too simple, and it can be accomplished as well in Java with
  static imports. But still, for my project it's being great (and cool) to
 do
  such things.
 
  object btnEditar extends Button(btnEditar) {
override def onSubmit() = {
  -/* show fields */
  -camposForm.setVisibilityAllowed(true)
  -btnSalvar.setVisibilityAllowed(true)
  -cancelar.setVisibilityAllowed(true)
  -
  -/* hide them */
  -camposTela.setVisibilityAllowed(false)
  -btnEditar.setVisibilityAllowed(false)
  +show(camposForm, btnSalvar, cancelar)
  +hide(camposTela, btnEditar)
}
  }
  add(btnEditar)
 
  Methods show/hide are imported as import code.DSLWicket._
 
 
 
  *Bruno Borges*
  www.brunoborges.com.br
  +55 21 76727099
 
 
 
  On Wed, Jul 27, 2011 at 4:53 PM, Bruno Borges bruno.bor...@gmail.com
 wrote:
 
  Thanks Martin,
 
  There was only a small little problem in your code. The correct syntax
 is:
 
  def label[T](id: String, model: IModel[T] = null): Label = { val label
  = new Label(id, model); add(label); label }
 
  The suggestions were updated on Gist.
 
  *Bruno Borges*
  www.brunoborges.com.br
  +55 21 76727099
 
 
 
  On Wed, Jul 27, 2011 at 3:55 PM, Martin Grigorov mgrigo...@apache.org
 wrote:
 
  Idea for simplification: use named parameters.
  For example
  def label[T](id: String, model: IModel[T]): Label = { val label = new
  Label(id, model); add(label); label }
  would become
  def label[T](id: String, model = _ : IModel[T]): Label = { val label =
  new Label(id, model); add(label); label }
 
  this way you'll have just one declaration of label function which will
  handle the current three
 
  additionally you may add a pimp:
  implicit def ser2model[S : Serializable](ser: S): IModel[S] =
  Model.of(ser)
 
  now even when you pass String as second param to label() it will be
  converted to IModel
 
  On Wed, Jul 27, 2011 at 9:11 PM, Martin Grigorov mgrigo...@apache.org
 
  wrote:
   Take a look at scala.swing.* sources.
  
   On Wed, Jul 27, 2011 at 8:34 PM, Bruno Borges 
 bruno.bor...@gmail.com
  wrote:
   Can some Scala expert help me to make this DSL available as PML
 (pimp
  my
   library)?
  
   I've tried to code it that way but things didn't quite worked out
 the
  way
   they should.
  
   The reason is that for every Wicket object I create, I must extend
 the
  trait
   DSLWicket
  
  
  
   *Bruno Borges*
   www.brunoborges.com.br
   +55 21 76727099
  
  
  
   On Wed, Jul 27, 2011 at 2:30 PM, Bruno Borges 
 bruno.bor...@gmail.com
  wrote:
  
   Not really.
  
   The method onSubmit() of button is void, as well onClick(), so
 there's
  no
   need for the function be passed as () = Unit or anything else.
  
   I made a few changes to it and updated on Gist.
  
   I've also uploaded a page that uses this DSL at
   https://gist.github.com/1109919
  
   Take a look
  
   *Bruno Borges*
   www.brunoborges.com.br
   +55 21 76727099
  
  
  
   On Wed, Jul 27, 2011 at 2:22 PM, Scott Swank 
 scott.sw...@gmail.com
  wrote:
  
   I think you do want Unit, which as I understand it is closest
   equivalent to void in Scala.
  
   http://www.scala-lang.org/api/current/scala/Unit.html
  
   Scott
  
   On Wed, Jul 27, 2011 at 10:14 AM, Bruno Borges 
  bruno.bor...@gmail.com
   wrote:
No, the function must return void, not another function (unit).
   
But there's also the option of () = Nothing. Which one should I
  use for
this case?
   
*Bruno Borges*
www.brunoborges.com.br
+55 21 76727099
   
   
   
On Wed, Jul 27, 2011 at 12:54 PM, Martin Grigorov 
  mgrigo...@apache.org
   wrote:
   
 def button(id: String, submit: () = Void): Button = {
   
it should be () = Unit, no ?
   
On Wed, Jul 27, 2011 at 6:51 PM, Martin Grigorov 
  mgrigo...@apache.org
   
wrote:
 Adding some usage examples at the bottom will help us
 evaluate
  it.

 Why not add type to
 def textField(id: String): TextField[_] = { val field = new
 TextField(id); add(field); field }
 to become
 def textField[T](id: String): TextField[T] = { val field =
 new
 TextField[T](id); add(field); field }

 

Non-Submit Button Not Getting Called from Form

2011-07-29 Thread eugenebalt
It's something simple that I'm forgetting, but my non-Submit button (e.g.
Cancel) is not getting called from my Form.

The button is a simple Button, not Ajax.


My HTML (using [] to avoid rendering here):

[form wicket:id=.. ]
  [input wicket:id=btnReturn type=button value=Return to Home Page
style=width: 300px /]
[/form]

My Java:

add(new Button(btnReturn) {

@Override
public void onSubmit() {
System.out.println(Clicked); 
   }

});


Thanks

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Non-Submit-Button-Not-Getting-Called-from-Form-tp3705651p3705651.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: resource problem..

2011-07-29 Thread eugenebalt
In the HTML, it would like this:

html
  head
titleLog In/title
wicket:link
link wicket:id=stylesheet/
/wicket:link
  /head
  body

   


So the WicketID CSS placeholder is where you would normally put a static CSS
declaration. Note the wicket:link around it.

Second, in Java,

add(new StyleSheetReference(stylesheet, SomeClass.class, main.css));

where SomeClass.java resides in the same folder as the file (in my case
main.css).

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/resource-problem-tp3697765p3705659.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: What does this syntax say?

2011-07-29 Thread Scott Swank
This is called a generic method, and you're just giving the type
signature of the method. Here's an example from our code.

public static T extends Number  ComparableT NumberFieldT
withMinimum(String id, T min) {
NumberFieldT f = new NumberFieldT(id);
f.add(new MinimumValidatorT(min));
return f;
}

Which allows:

NumberFieldInteger adultAge = NumberField.withMinimum(bar, 18);
NumberFieldFloat rating = NumberField.withinRange(foo, 0.0, 5.0);

Scott





On Thu, Jul 28, 2011 at 11:55 PM, Wilhelmsen Tor Iver
toriv...@arrive.no wrote:
 public W IWrapModelW wrapOnInheritance(Component component,ClassW
 type)

 The ClassW parameter is only needed if you intend to do new W(); or the 
 like in the method (the Class is then something the compiler can grab hold of 
 for calling the constructor). For just passing the type parameter to other 
 generic classes it is not needed. The compiler sees the context (i.e. the 
 left-hand side of an assignment) and if it cannot determine the type it will 
 say needs a cast as a warning, but the code will compile since it's all 
 Object anyway.

 - Tor Iver


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



Re: Non-Submit Button Not Getting Called from Form

2011-07-29 Thread hariharansrc
Actually what you will do when clicking cancel override onSubmit event
similarly like other buttons

https://cwiki.apache.org/WICKET/multiple-submit-buttons.html

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Non-Submit-Button-Not-Getting-Called-from-Form-tp3705651p3705817.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Advanced Mounting Markup Location

2011-07-29 Thread Arjun Dhar
ok its embarassing to have to post the answers to your questions, heh but
this is one is for less fortunate:

In my application I could pass the Class of the MarkupContainer (rather than
the class that loads the markup)

/**
 * The {@link 
DefaultMarkupResourceStreamProvider#getMarkupResourceStream};
derives the path 
 * from the Class? containerClass and passes it to the {@link
IResourceStreamLocator#locate} method.br /
 * It also passes the MarkupContainer class to the {@link
IResourceStreamLocator#locate} method. This class is useless in our case,
 * and there is more value in getting the actual Class? 
containerClass.
Simple swap which class is passed to the locate mothod.
 */
protected void tweakMarkupCacheStreamProvider() {
getMarkupSettings().setMarkupCache(new MarkupCache(this) {
private IMarkupResourceStreamProvider 
markupResourceStreamProvider;

/**
 * Get the markup resource stream provider to be used
 * 
 * @param container
 *The MarkupContainer requesting the markup 
resource stream
 * @return IMarkupResourceStreamProvider
 */
protected IMarkupResourceStreamProvider 
getMarkupResourceStreamProvider(
final MarkupContainer container)
{
if (container instanceof 
IMarkupResourceStreamProvider)
{
return 
(IMarkupResourceStreamProvider)container;
}

if (markupResourceStreamProvider == null)
{
/*
 * Most of the code of the original 
{@link
DefaultMarkupResourceStreamProvider} is untouched,
 * except the line that calls the 
locate(...) method!
 */
markupResourceStreamProvider = new
DefaultMarkupResourceStreamProvider() {
public IResourceStream 
getMarkupResourceStream(final MarkupContainer
container, Class? containerClass)
{
...
...
//container.getClass() 
replaced with containerClass below :::
IResourceStream 
resourceStream = locator.locate(containerClass, path,
style, locale, ext); 
...
...
}   

};
}
return markupResourceStreamProvider;
}   
});
}


Request to the Developers ::
One particularly disturbing thing I've seen in certain wicket components
(maybe an oversight); is that if you dont have POJO style getter() 
setter() on your components; then non final variables should be declared
protected not private. There is no point providing overriding methods that
use private variables, to which the child class has no access.

thanks


-
Software documentation is like sex: when it is good, it is very, very good; and 
when it is bad, it is still better than nothing!
--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Advanced-Mounting-Markup-Location-tp3705032p3705848.html
Sent from the Users forum mailing list archive at Nabble.com.

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