In fact, the example createLabel is not really the most interesting. Let's me
explaining what I consider as a good candidate and what I have done
1) A HTML page contains a table which is populated dynamically using a
service collecting data from a DB. the last column of the table is a link
ok, i understand, thanks,
NM
On Tue, Sep 22, 2009 at 9:45 PM, Jeremy Thomerson jer...@wickettraining.com
wrote:
It's the same reason you shouldn't use new Label(id
object.getSomeText());. See this example:
public MyPage () {
Person p = getPersonFromSomewhere();
Label l = new
hi Charles
The whole issue is that you don't know how the data (in this case a
String) is to be retrieved. Can it be read only once ? Should it be
refresh on each request cycle ? On each access to the data ? Does it come
from a database ?
Wicket's model allows you to go away from all these
Jeremy:you say 2 - don't call setEnabled() - override isEnabled
why is better override isEnable then setEnable?
thanks NM
On Mon, Sep 21, 2009 at 9:44 AM, cmoulliard cmoulli...@gmail.com wrote:
Joseph,
Can you explain a little bit what you mean by provide it with attribute
(IModelString)
It's the same reason you shouldn't use new Label(id
object.getSomeText());. See this example:
public MyPage () {
Person p = getPersonFromSomewhere();
Label l = new Label(numberOfPhoneNumbers, p.getPhoneNumbers().size());
l.setVisible(p.getPhoneNumbers().size() 0);
new
Joseph,
Can you explain a little bit what you mean by provide it with attribute
(IModelString) ?
private Label labelTitle;
public static Label createLabelTitle(String title) {
return new Label(title,new Model( title ));
}
-- becomes
private
This is because you're not using models correctly. And you apparently are
not using page inheritance either. Both of those things will fix this
problem that you describe. Also, Wicket makes it *very* easy to create
reusable code - in your link example, just make a subclass of link as a
concrete
cmoulliard wrote:
(...)
I think that this is a general remark that some users make about Wicket. It
is very difficult to reuse part of the code.
Here is another example :
I have a label called id which is used in different page. The way proposes
by Wicket to code it is
Page Request
What I have done to avoid to repeat the creation of the labels is to define
and use static method
private Label labelTitle;
public static Label getLabelTitle(String title) {
return new Label(title,new Model( title ));
}
Joseph Pachod wrote:
cmoulliard wrote:
What I have done to avoid to repeat the creation of the labels is to define
and use static method
private Label labelTitle;
public static Label getLabelTitle(String title) {
return new Label(title,new Model( title ));
}
I personally
Sure, just create it (including the onClick which might be invalid), but
afterwards set the setEnabled() as needed.
As long as the link is disabled, it can never be clicked thus the
onClick() will never be executed anyway, so it's irrelevant if the
requestFormModel is valid or not...
I dont
You are right. I don't need the setEnabled(false) in the onClick method
I have changed my code :
link = new Link(linkRequest) {
@Override
public void
Hi
As I said in my previous mail, just initialize the link once using the
upper variant.
Use an if before to create the requestFormModel, in case 2, the
requestFormModel can be null - as the onClick is never executed this
will not matter.
Have something like:
final Model requestFormModel;
Mattias,
OK about what you propose but we repeat the test a second time so the code
still remains very verbose.
Thanks for the suggestion.
I think that this is a general remark that some users make about Wicket. It
is very difficult to reuse part of the code.
Here is another example :
I have
Hi
Yes there'll always be some repetition. Depending on your logic you
might also stuff the first block in the onClick event to generate the
model if it's not used anywhere else. That could eliminate the first block.
The problem about reusable components in wicket is that probably you
might
15 matches
Mail list logo