Re: DataTable's FilterToolbar generics broken

2014-05-02 Thread Leszek Gawron
Confused I am not :)


Let me give you three examples...

I. filtering with a subset of properties

This is a class that worked perfectly in 1.4.19:
public class CustomersDataProvider extends
HibernateDataProvider implements
IFilterStateLocator {
@SuppressWarnings("unused")
public static class CustomerFilter implements Serializable {
private Stringname;
private Stringnip;

public String getName() {
return name;
}

public void setName( String name ) {
this.name = name;
}

public String getNip() {
return nip;
}

public void setNip( String nip ) {
this.nip = nip;
}
}

private CustomerFilterfilter= new CustomerFilter();

public CustomersDataProvider() {
super( Customer.class );
setSort("name",
true );
}

@Override
public CustomerFilter getFilterState() {
return filter;
}

@Override
public void setFilterState( CustomerFilter state ) {
filter = (CustomerFilter) state;
}

@Override
public IModel model( Customer object ) {
return new CustomerModel( object );
}

@Override
protected void filter( Criteria c ) {
CriteriaHelper.ilike(c,
"name",
filter.getName() );
CriteriaHelper.ilike(c,
"nip",
filter.getNip() );
}
}

why? Customer is a class with lots of properties. I am unable to
provide proper filtering for all properties so I create a
CustomerFilter having only two properties: name and nip. This way I am
stating to other developers that my IDataProvider filters by two
properties only.


II. filtering date properties

Let's have a Sale entity with "date" property. Dates are usually
filtered by date ranges. So in filter I need startDate and finishDate
with two inputs rather than one (Sale.date). It is impossible if the
filter does not differ from base collection type.

with wicket 1.4.19 it was:

@Getter @Setter
public class SaleFilter implements Serializable {
private DatedateFrom;
private DatedateTo;
private StringcustomerName;
private Stringdescription;
private Statusstatus;
private GroupingModegroupingMode;
}

class SalesDataProvider extends HibernateDataProvider implements
IFilterStateLocator {
private SaleFilterfilter= new SaleFilter();
private final LongcustomerId;

public SalesDataProvider( Long customerId ) {
super( Sale.class );
this.customerId = customerId;

setSort("date",
false );
}

@Override
protected Criteria setupCriteria( Session session ) {
Criteria c = super.setupCriteria( session );
c.createAlias("customer",
"customer" );
return c;
}

@Override
protected void filter( Criteria c ) {
if ( customerId != null )
c.add( Restrictions.eq( "customer.id",
customerId ) );
else if ( !StringUtils.isBlank( filter.getCustomerName() ) )
CriteriaHelper.ilike(c,
"customer.name",
filter.getCustomerName() );

CriteriaHelper.dateFilter(c,
"date",
filter.getDateFrom(),
filter.getDateTo() );

CriteriaHelper.ilike(c,
"description",
filter.getDescription() );

if ( filter.getStatus() != null )
c.add( Restrictions.eq( "status",
filter.getStatus() ) );

if ( filter.getGroupingMode() != null )
c.add( Restrictions.eq( "groupingMode",
filter.getGroupingMode() ) );
}

@Override
public IModel model( Sale object ) {
return new SaleModel( object );
}

@Override
public SaleFilter getFilterState() {
return filter;
}

@Override
public void setFilterState( SaleFilter state ) {
this.filter = state;
}
}


III. filtering with a superset of properties

Lets design a data provider for Order.

How would you create a filter for orders containing a selected
product? Probably so:

@Getter @Setter
public class OrderFilter implements Serializable {
private Date creationStartDate;
private Date creationFinishDate;
private String customerName;
private Long selectedProductId;
}

In this case the filter contains MORE pro

DataTable's FilterToolbar generics broken

2014-04-26 Thread Leszek Gawron
I started migrating my code from wicket 1.4.19 to 6. Finally ! :)

I found a FilterToolbar bug:

Once you were able to create DataTable wrapped inside of
FilterForm

currently FilterToolbar requires you for those two types to be identical:

public  FilterToolbar(final DataTable table, final
FilterForm form,
final IFilterStateLocator stateLocator)

It looks like commit 9b3f9ca1df064fe9c6fde64ccc37fecc504b09a6
introduced a bug long time ago and it carried on:

-   public  FilterToolbar(final DataTable table, final
FilterForm form,
+   public  FilterToolbar(final DataTable table, final
FilterForm form,


FilterToolbar constructor should state:

public  FilterToolbar(final DataTable table, final
FilterForm form,
final IFilterStateLocator stateLocator)


cheers.

-- 
Leszek Gawron

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



Wicket TinyMCE 1.4.18 fails

2011-10-07 Thread Leszek Gawron

with the message in JS console:

/app/resources/wicket.contrib.tinymce.InPlaceEditBehavior/tiny_mce/themes/advanced/editor_template_src.js:128
Uncaught TypeError: Cannot call method 'push' of undefined

and it didn't so for 1.4.17.

Could anybody confirm this?

    lg
--
Leszek Gawronhttp://lgawron.posterous.com

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



wicket as template engine

2011-07-19 Thread Leszek Gawron
I know I could use freemarker, velocity or any other tool. But these 
tools require me to create a full blown template model up front as 
wicket allows for a bunch of models chained togeter pulling data from 
different sources when they are needed.


I have a set of load of panels that create a single Page. The customer 
wants me to export page contents to pdf so I thought I could:


 1. create a "print" skin for the panels
 2. render the panels/page using "print" skin to the external html file.
 3. use some html to pdf rendering tool (like flying saucer)
 4. serve pdf as with content-disposition: attachment

Everything is easy apart from 1). Can you advise?

    lg
--
Leszek Gawronhttp://lgawron.posterous.com

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



Panel factories and @SpringBean

2011-03-04 Thread Leszek Gawron

Hello,

Let's say I want to write some UI to edit some complicated configuration 
split into multiple entities in multiple maven modules. The UI needs to 
have one entry point though. So:


Let's create the UI based on TabbedPanel. Each of the tabs will be 
provided by different maven modules by the means of factories:


 > public interface JukeboxConfigPanelFactory extends Ordered {

public IModel getPanelTitle();

public Panel getPanel( String id, IModel jukeboxModel );
}




Provided that I have a list of all panel factories (that is an actual 
problem!) I can do that:




List tabs = new ArrayList();

for ( JukeboxConfigPanelFactory factory : getPanelFactories() ) 
{
tabs.add( new 
JukeboxConfigPanelFactoryAwareAbstractTab( factory, getJukeboxModel() ) );
}

add( new AjaxTabbedPanel( "tabs", tabs ) );


The problem is: HOW do I get all the panel factories defined in Spring 
context?


I cannot do :

@SpringBean
private List factories;

because this is not supported by 
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.


I could create another spring bean:


public interface JukeboxConfigPanelFactoryManager {
public List getPanelFactoryList();
}




@Component
public class JukeboxConfigPanelFactoryManagerImpl implements 
JukeboxConfigPanelFactoryManager, InitializingBean {
private List   factoryList;

@Autowired
public JukeboxConfigPanelFactoryManagerImpl( 
List factoryList ) {
this.factoryList = factoryList;
}

@Override
public List getPanelFactoryList() {
return Collections.unmodifiableList( factoryList );
}

@Override
public void afterPropertiesSet() throws Exception {
Collections.sort(   factoryList,
new OrderComparator() );
}
}


so now I am able to get all factory implementations in one place:


List tabs = new ArrayList();

for ( JukeboxConfigPanelFactory factory : 
panelFactoryManager.getPanelFactoryList() ) {
tabs.add( new 
JukeboxConfigPanelFactoryAwareAbstractTab( factory, getJukeboxModel() ) );
}

add( new AjaxTabbedPanel( "tabs", tabs ) );


But now the JukeboxConfigPanelFactoryAwareAbstractTab will fail 
miserably at serializing as only the manager has been wrapped with a 
proxy and not the factories underneath.


How can I approach the problem using current state of wicket-spring 
module? I haven't found a way to wrap the "factory" beans with proxy 
manually.


--
Leszek Gawron  http://lgawron.blogspot.com

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



Re: Free wicket from component hierarchy hell

2010-11-05 Thread Leszek Gawron

On 2010-11-05 09:37, Martin Makundi wrote:

LibA provides PanelA which exports ComponentA with id == "messages" (e.g.
ListView) with Page scope.


PanelA defines independent namespace.


LibB provides PanelB which exports ComponentB with id == "messages" (e.g.
DataGrid) with Page scope.


PanelB defines independent namespace.


Then your application has a page MyPage which includes both PanelA and
PanelB and the problem arises.


MyPage defines new namespace.

PanelA and PanelB are independent.

No problems.


and what about :

add( new PanelA( new Model1() );
add( new PanelA( new Model2() );
add( new PanelA( new Model3() );

to the same page ?

--
Leszek Gawron  http://lgawron.blogspot.com

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



Re: Trying to submit form with id that is not in document.

2010-10-29 Thread Leszek Gawron

On 2010-10-29 14:06, Maris Orbidans wrote:

Hi

I have a modal window with a panel inside it. After I refresh the panel
via ajax all buttons inside the panel stop working. Submit doesn't work
and there is this message in ajax debug window:

ERROR: Wicket.Ajax.Call.submitFormById: Trying to submit form with id
'categoryListForm135' that is not in document.


This is relevant output from ajax debug:







As you can see there is form with id "categoryListForm135".
For some reason javascript cannot find it.


Panel html:




 

 
 
 Name
 Description
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 



When it happens there is javascript error "form is null" in
wicket-ajax.js

submitFormById: function(formId, submitButton) {
var form = Wicket.$(formId);
if (form == null || typeof (form) == "undefined")
Wicket.Log.error("Wicket.Ajax.Call.submitFormById: Trying to submit form
with id '"+formId+"' that is not in document.");
return this.submitForm(form, submitButton);
},
submitForm: function(form, submitButton) {
if (form.onsubmit) {//   ERROR IS HERE
if (!form.onsubmit()) return;
}
if (this.handleMultipart(form, submitButton)) {
return true;
}
var body = function() {
var s = Wicket.Form.serialize(form);
if (submitButton != null) {
s += Wicket.Form.encode(submitButton) + "=1";
}
return s;
}
return this.request.post(body);


Any idea what can be wrong?


yes ... your modal window has to be put into a form, so the panel's form 
is nested:


Example:


public class TrackerGroupsPanel extends Panel {
@SpringBean
private FleetServicefleetService;
@SpringBean
private TrackerService  trackerService;

private ModalWindow modalWindow;
protected FeedbackPanel feedback;

public TrackerGroupsPanel( String id, final IModel model ) {
super( id, model );
setOutputMarkupId( true );

add( new Form( "form" ) {
{
add( feedback = new FeedbackPanel( "feedback" ) 
);
feedback.setOutputMarkupId( true );

add( modalWindow = new ModalWindow( 
"modalWindow" ) );
modalWindow.setWindowClosedCallback( new 
WindowClosedCallback() {
@Override
public void onClose( AjaxRequestTarget 
target ) {
target.addComponent( 
TrackerGroupsPanel.this );
}
} );

add( new AjaxLink( "registerGroup", 
model ) {
@Override
public void onClick( AjaxRequestTarget 
target ) {
modalWindow.setTitle( "Nowa grupa 
pojazdów" );
modalWindow.setContent( new 
TrackerGroupPanel( modalWindow.getContentId(), Model.of( new TrackerGroup(

getModelObject() ) ) ) {
@Override
protected void onSave( 
AjaxRequestTarget target ) {

modalWindow.close( target );
}

} );
target.addComponent( feedback );
modalWindow.show( target );
}
} );

[...]


then you will hit another bug if your form starts using ajax onchange 
notifications ... but that is another tale :)


--
Leszek Gawron  http://lgawron.blogspot.com

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



Re: Bean injection

2010-10-07 Thread Leszek Gawron

On 2010-10-07 04:51, Mauro Ciancio wrote:

Hello everyone,
   I'm using spring in one wicket project and I'm lost about how the
proxy stuff works. I've realized that the fields marked with
@springbean are injected when the component injection listener runs.

   Also, I've looked in AnnotProxyFieldValueFactory.class to find out
how the bean proxy is created and how it can be serialized.

   Now, this is my issue. The page is created by wicket, the injection
is done and I have the bean ready for use. If the page is serialized,
the bean will be reconstructed using the bean factory (through the
proxy). But, somehow when I click a non bookmarkable link in my page,
the bean is never reconstructed and I have the previous reference to
the bean (I mean, the same object).

   Is this the correct behavior? Shouldn't this bean be reconstructed
when another request arrives?

   BTW, I've defined all the beans with prototype scope, so it's not a
spring issue.


AFAIR the once the bean is looked up from spring it is being cached by 
AnnotProxyFieldValueFactory itself.


So using prototype scope will not work anyway: either way you always get 
a fresh bean (so you cannot keep state) or you will always get the same 
bean (even worse if the bean is stateful).


You probably should convert your code to using singleton beans and pass 
appropriate state from wicket component itself.


lg

--
Leszek Gawron  http://lgawron.blogspot.com

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



Re: any good ideas about how to add a confirm check before leaving a page?

2010-08-10 Thread Leszek Gawron

On 2010-08-10 15:11, Joe Hudson wrote:

Thank you very much for the response but my issue is not a simple as this

Say I have a page with navigation links and the page doesn't "know" about the 
navigation links because they are controlled by functionality provided in the superclass. 
 What I am trying to do is deal with the case where the user clicks a link of that type 
and intercept that event.  Does anyone have any advice?  Thanks.


Do you need to intercept the event or just as user for permission to 
leave the page? If the latter:


https://cwiki.apache.org/WICKET/composite-behaviors.html



--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



Re: DataView/LoadableDetachableModel/onClick

2010-08-10 Thread Leszek Gawron

On 2010-08-09 18:18, Igor Vaynberg wrote:

it is not recommended to pass models between pages because if the
model is anonymous it can carry with it a reference to the other page
object and your session size will spike because your page also has a
reference to the previous page.

so no, it shouldnt be that.


that is why I use model classes which are nested private static and get 
the best out of both approaches.


Still I thought that you have been debating on "smart serialization of 
anonymous models" and making them safe to use. Am I wrong?




-igor

On Mon, Aug 9, 2010 at 12:19 AM, Leszek Gawron  wrote:

On 2010-08-09 05:32, Igor Vaynberg wrote:


  final Customer customer = item.getModelObject();
...   Link link = new Link("link") {
public void onClick()   {
setResponsePage(new CustomerPage(customer));

the line above holds on to the customer object, so the Link subclass
has a reference to customer. instead
...   Link link = new Link("link", item.getmodel()) {
public void onClick()   {

setResponsePage(new
CustomerPage((Customer)getmodelobject()));



--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



Re: DataView/LoadableDetachableModel/onClick

2010-08-09 Thread Leszek Gawron

On 2010-08-09 05:32, Igor Vaynberg wrote:

  final Customer customer = item.getModelObject();
...   Link link = new Link("link") {
public void onClick()   {
setResponsePage(new CustomerPage(customer));

the line above holds on to the customer object, so the Link subclass
has a reference to customer. instead
...   Link link = new Link("link", item.getmodel()) {
public void onClick()   {

setResponsePage(new
CustomerPage((Customer)getmodelobject()));


shouldn't it actually be :

Link link = new Link( "link, item.getModel() ) {
  public void onClick() {
  setResponsePage( new CustomerPage( getModel() ) );
  }
}

?

--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



Re: RE: back link

2010-08-08 Thread Leszek Gawron
Well ... first off the code was written out the top of my head and as it is
totally trivial there should be no problem there is a typo somewhere.

Answering your second concern: no it shouldn't be built-in in:
- it breaks pages' statelessness
- the web navigation is hardly ever linear so you always need to tweak it
for your needs.
- when you put ajax info the picture you need to come up with another
approach.

Cheers

W dniu 2010-08-09 02:33 użytkownik "Alex Rass"  napisał:

Well, first off, there's a bug:


> setResponsePage( new TargetPage( new SomeModel(),
> Originatin...
Needs to be part of constructor call:


> setResponsePage( new TargetPage( new SomeModel(),
>   OriginatingPage.this )  );

Second of all: this seems so "dirty".
Doing this means that for something THIS simple and common, you need to go
and change ALL your page's constructors?

Yes, I can go through the types of Pages and inherit them all once and add
all features I need into them, but it also seems like it's something that
should be inherent/built in, no?

- Alex


>-Original Message-
>From: Leszek Gawron [mailto:lgaw...@gmail.com] On Behalf Of Leszek
Gaw...


Re: back link

2010-08-07 Thread Leszek Gawron
On Saturday, August 7, 2010, Chris Colman  wrote:
> Does this work for clicking 'back' n times where n > 1 or does it only
> work in the n = 1 case?

Yes it does. Please mind though that the pagemap size is limited so
you might get "page expired" for large n values. I have never
experienced the problem for n values  up to 10-15...

  LG

-- 
Leszek Gawron

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



Re: relationship of DAO to IDataProvider and DetachableLoadableModel

2010-08-06 Thread Leszek Gawron

On 2010-08-06 22:58, Chris Merrill wrote:

On 8/6/2010 4:35 PM, Leszek Gawron wrote:

you can actually do it in any class you like :)


So I was about to ask how this works on deserialization, since the constructor 
will not
be called.  Then I re-read your previous and I think I now understand this

"Injector injects a serializable proxy instead of the bean directly."

So I guess this serializable proxy knows how to re-create the DAO when the bean 
is
deserialized (possibly on another server?).  Very nice!  I'm (slowly) starting 
to
understand the role that Spring plays.


in fact the dao is not "re-created" as "re-looked up" every time 
deserialization takes place. And yes - it does "survive" clustering (I 
never tried it though).


If you want more insight check the source code of wicket-spring module, 
especially:


org.apache.wicket.spring.injection.annot.AnnotSpringInjector

org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory [1]


javadoc:

lg

[1] 
http://wicketbyexample.com/api/wicket-spring/latest/org/apache/wicket/spring/injection/annot/AnnotProxyFieldValueFactory.html


--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



Re: relationship of DAO to IDataProvider and DetachableLoadableModel

2010-08-06 Thread Leszek Gawron
On Fri, Aug 6, 2010 at 10:30 PM, Chris Merrill  wrote:
> Wow, that was easy! Thanks!!
>
> Now, do I do the same thing in my LoadableDetachableModel?  (so that load() 
> can get
> access to the DAO as well)  Should detach() be doing anything related to this?

you can actually do it in any class you like :)
you do not have to do anything in detach() for this scenario

  lg

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



Re: relationship of DAO to IDataProvider and DetachableLoadableModel

2010-08-06 Thread Leszek Gawron

On 2010-08-06 20:43, Chris Merrill wrote:

I've been away from server-side development for quite a while...working on a 
massively
multi-threaded network-centric Eclipse-based app .  I'm now working on a 
proof-of-concept for the
technology stack for an upcoming project web-based product and am trying to get 
my head around
Wicket, JPA, IOC, dependency injection, etc.

I have the first stage of the prototype together, but I'm not sure I have it 
assembled correctly,
specifically related to DetachableLoadableModel, IDataProvider and 
container-injected entity managers.

I'm using Spring to inject the Entity Manager into my DAO-ish DB logic wrapper 
(AppDAO).

There is a "ItemsPage" that lists items from a database table using a DataView 
with a
SortableItemProvider (SortableDataProvider) and a PagingNavigator.  It 
also has a member
AppDAO that is a @SpringBean. The page uses a SortableItemProvider 
(SortableDataProvider) to
provide data for the DataView.

The SortableItemProvider receives an AppDAO instance from the page (as a 
constructor parameter)
during the page constructor and stores it as a member variable.  It then passes 
the AppDAO off to
the DetachableItemModel (DetachableLoadableModel) when it creates them.


public class MyDataProvider ... {

@SpringBean
private AppDAO appDao;

public MyDataProvider() {
 InjectorHolder.getInjector().inject( this );
}

}

and you'll be fine. You do not have to pass it from the page.

Injector injects a serializable proxy instead of the bean directly.

--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



Re: SV: back link

2010-08-06 Thread Leszek Gawron

On 2010-08-06 14:29, Wilhelmsen Tor Iver wrote:

public TargetPage( IModel  model, final Page returnPage ) {


You should use PageReference objects instead to avoid issues with serialization.

- Tor Iver

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

AFAIU pages refered in other pages are in fact automatically serialized 
as PageReferences. Am I wrong? Has the serialization magic been removed?


lg

--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



Re: back link

2010-08-06 Thread Leszek Gawron

On 2010-08-06 13:44, Alex Rass wrote:

Hi.

Here's a "cooky-wacky" problem:

Added this to my markup:
Back

But when I am running this under the wicket (w/ FFox),  it works great once.
Then it starts jumping me back to this page after I leave it.

Is there something I should be doing differently to create a back button? :)
I know this is an HTML/JS question, but this is a typical thing to do in
HTML and it usually works, afaik.


this might be the typical way but probably the worst ever ...

You are better of with something like this :

public class OriginatingPage extends WebPage {
  public OriginatingPage() {
 add( new Link( "targetPage" ) {
   public void onClick() {
 setResponsePage( new TargetPage( new SomeModel(),
  OriginatingPage.this );
   }
 }
  }
}


public class TargetPage extends WebPage {
  public TargetPage( IModel model, final Page returnPage ) {
super( model );
add( new Link( "back" ) {
  public void onClick() {
setResponsePage( returnPage );
  }
}
  }
}


You can use analogous technique for panel replacement.

this way it always 100% predictable (and BTW works when javascript is 
not available: javascript turned off, dummy browsers on mobile devices).


--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



PanelCachingTab

2010-02-15 Thread Leszek Gawron

hello,

is there any reason why PanelCachingTab.isVisible() does not delegate to 
inner tab ?. This results in such spaghetti code:




tabs.add( new PanelCachingTab( new AbstractTab( new ResourceModel( 
"configuration" ) ) {
@Override
public Panel getPanel( String panelId ) {
return new UnitConfigurationPanel( panelId, 
getModel(), notificationsPanel );
}
} ) {
@Override
public boolean isVisible() {
MonitoringUserDetails userDetails = 
(MonitoringUserDetails) UserUtils.getPrincipal();
return 
userDetails.getMonitoringUser().isConfigurationAccess();
};
});



    lg

--
Leszek Gawron  http://lgawron.blogspot.com

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



Re: Wicket Wizard previous

2010-01-11 Thread Leszek Gawron

nino martinez wael wrote:

Just empty the page map?


you can always try with:

WizardModel wizardModel = new WizardModel() {
  public boolean isPreviousAvailable() { return false; }
}

--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



Re: Customized FeedbackPanel question

2009-12-03 Thread Leszek Gawron

Igor Vaynberg wrote:

why dont you simply check in your filter if the reporter component is
a descendant of the form and then ignore the message?


I have the same problem. If you build a heavy componentized page with 
lots of panels your solution is hard to implement.


Lets say there are on the page:
 - some panels has it's own FeedbackPanel (properly filtered)
 - some panels with no FeedbackPanel

Is there a possibility to put a "global" FeedbackPanel on the page and 
put in it ONLY the messages that have been filtered out by every "local" 
 FeedbackPanel?


Or the other way around: global FeedbackPanel filters out anything that 
 local FeedbackPanels accept.


    lg
--
Leszek Gawron  http://lgawron.blogspot.com

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



Re: AjaxFallbackLink does not work on Windows Mobile Internet Explorer

2009-12-03 Thread Leszek Gawron

Richard Wilkinson wrote:

Actually I've just realiaed, you can't remove the behaviour with component
instansiation because it hasn't been added yet. Look at
ibeforeonbeforerenderlistener. Its called something like that, can't check
at the moment.


Thank you, you've been very helpful. This code did the trick:


addPostComponentOnBeforeRenderListener( new IComponentOnBeforeRenderListener() {
@Override
public void onBeforeRender( Component component ) {
List behaviors = component.getBehaviors();
for ( IBehavior behavior : behaviors ) {
if ( AjaxEventBehavior.class.isAssignableFrom( 
behavior.getClass() ) ) {
AjaxEventBehavior aeb = (AjaxEventBehavior) 
behavior;
if ( aeb.getEvent().equalsIgnoreCase( "onclick" 
) )
component.remove( behavior );
}
}
}
} );


works like a charm.
    
    lg

--
Leszek Gawron  http://lgawron.blogspot.com

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



AjaxFallbackLink does not work on Windows Mobile Internet Explorer

2009-12-02 Thread Leszek Gawron
it seems that Mobile IE understands "onclick" a little bit to start 
running it but not enough to actually process the request so no actual 
fallback is being made.


As I would really like to keep my code as it is I thought I would 
introduce "Simple HTML" mode which would strip all "onclick" tags and 
leave the browser with the href="" tags it understands. Is there any 
elegant way to do it globally?


lg

--
Leszek Gawron  http://lgawron.blogspot.com

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



DataTable's toolbars broken in 1.4.2 and 1.5-SS

2009-10-04 Thread Leszek Gawron

I have found the issue: https://issues.apache.org/jira/browse/WICKET-2436

and commented there. Still the issue remains in fixed state. Is there 
anything else I should do?


lg

--
Leszek Gawron  http://lgawron.blogspot.com

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



Re: "conditional" form validators (nested forms issue)

2009-05-22 Thread Leszek Gawron

No no .. This is exactly the opposite of what I want.

I cannot setDefaultFormProcessing to false for Wizard buttons - some 
screens may need other settings.


I need the nested form validators NOT to fire when pressing wizard 
navigation buttons.


Juan Carlos Garcia M. wrote:

Set Button#setDefaultFormProcessing(false)

Also check:  http://cwiki.apache.org/WICKET/multiple-submit-buttons.html
multiple-submit-buttons 



Leszek Gawron-2 wrote:

Hello,

say i have a small form :

   * first name - text field required
   * last name - text field required
   * phone no - text field required
   * submit button to add new contact

everything works fine until I put the form into a wizard step. It turns 
out that wizard itself is a form. So now we have :


wizard
   - some refreshing view
   - add contact form
 * first name - text field required
 * last name - text field required
 * phone no - text field required
 * submit button to add new contact
   - wizard navigation buttons

Pressing wizard "Next" button makes addContactForm validate which raises 
  required text fields errors. You cannot leave the step.


Is there a way to fire form/field validators only if a specific button 
has been pressed?

    lg

--
Leszek Gawron

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








--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.

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



"conditional" form validators (nested forms issue)

2009-05-21 Thread Leszek Gawron

Hello,

say i have a small form :

  * first name - text field required
  * last name - text field required
  * phone no - text field required
  * submit button to add new contact

everything works fine until I put the form into a wizard step. It turns 
out that wizard itself is a form. So now we have :


wizard
  - some refreshing view
  - add contact form
* first name - text field required
* last name - text field required
* phone no - text field required
* submit button to add new contact
  - wizard navigation buttons

Pressing wizard "Next" button makes addContactForm validate which raises 
 required text fields errors. You cannot leave the step.


Is there a way to fire form/field validators only if a specific button 
has been pressed?

    lg

--
Leszek Gawron

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



Re: Equivalent of StackPanel for Wicket

2009-03-26 Thread Leszek Gawron

HHB wrote:

Hey,
I want to employ something like StackPanel of GWT in my Wicket application.
Any production ready component?
Thanks for help and time. 


the easiest way is to use jQuery, the accordion widget in particular:

http://jqueryui.com/demos/accordion/

--
Leszek Gawron

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



Re: Wicket WebBeans Project...

2009-03-19 Thread Leszek Gawron

James Carman wrote:

All,

I've run into a problem.  I'd like to start up a project to integrate
the new WebBeans Specification (JSR-299) based on the Apache
OpenWebBeans project
(http://incubator.apache.org/openwebbeans/1.0.0-SNAPSHOT/index.html)
in the Apache Incubator.  Unfortunately, there already exists a
project called wicketwebbeans.  It's not an "official" Wicket project,
but I don't want to step on anyone's toes.  What would you folks
suggest here?  The name of the spec is WebBeans, so the name
wicket-webbeans (the packages is javax.webbeans) does fit.  The other
project's actual name is wicketwebbeans, so it's not an exact match,
but it's close enough to cause some confusion.


you could call it wicket-jsr299, but that might be a little bit too 
cryptic for some users...


Is wicketwebbeans project active currently? It looks like it's still 
using wicket 1.3...


--
Leszek Gawron

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



Re: Wicket:enclosure does not work with navigation toolbar of data table

2009-03-19 Thread Leszek Gawron

Robin Shine wrote:
Hi All, 


It seems that the navigation toolbar of data table component can not be 
displayed if there is a link on the page surrounded with the wicket:enclosure 
tag. Here is my very simple test case:

TestPage.html:

http://www.w3.org/1999/xhtml";>




link




TestPage.java:

package test;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import 
org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import 
org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.IDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

public class TestPage extends WebPage {
public TestPage() {

add(new Link("link") {
@Override
public void onClick() {
}
@Override

public boolean isVisible() {
return false;
}
});
AbstractColumn[] columns = new AbstractColumn[]{
new AbstractColumn(new Model("value")) {
public void populateItem(Item cellItem, String componentId, IModel rowModel) {
cellItem.add(new Label(componentId, rowModel.getObject().toString()));
}
},

};
IDataProvider dataProvider = new IDataProvider() {
public Iterator iterator(int first, int count) {
List values = new ArrayList();
for (int i=0; iThe navigation toolbar of the data table is not displayed. However if the "wicket:enclosure" tag is removed from the template, the toobar then displays correctly. 


Is this a bug? Or is there anything obvious I missed?


I stumbled upon exactly the same poblem. The only thing I can tell you: 
you don't need wicket:enclosure in your case. Simply remove the tag and 
as Link.isVisible returns false it will not be rendered.


If you put anything else apart from  into wicket:enclosure you 
should see correct behavior.


This probably IS a bug. File a JIRA request for that.

--
Leszek Gawron

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



Re: Updating the model of PasswordTextField

2009-03-17 Thread Leszek Gawron

vela wrote:

Hello,

I have a PasswordTextField , AjaxFallbackLink, and some text field. On click
of the AjaxFallback, i am able to reset the content of the other text files
using setModelObject("values"). But when i try to setModelObject for the
PasswordTextField, it is not reflecting in the PasswordTextField.

How to achieve it?
What is the reason for it?


Dod you look at PasswordTextField.setResetPassword( boolean )?


--
Leszek Gawron

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



Re: How can I injecting a Springbean into a custom session.

2009-03-06 Thread Leszek Gawron

CrocodileShoes wrote:

By the way is this safe to use in any Wicket component, for example, a Panel?

I can't think of any reason why not, but this is my first foray into web
development.


Yes it is. @SpringBean creates a proxy to your spring bean so there are 
no serialization issues.


--
Leszek Gawron

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



Re: Non-serializable model objects

2009-03-06 Thread Leszek Gawron

Timo Rantalaiho wrote:

On Tue, 03 Mar 2009, Chris Hansen wrote:

The situation that I'm dealing with most commonly is where I'm dealing
with simple, DTO-like POJOS with no-arg constructors and
getters/setters (why they are not serializable in the first place is
beyond me). It just seems like it would be possible, in this simple
case, to create a proxy for each object in the object graph which is
not serializable until you get down to the actual data (i.e.
primitives, Strings, etc.) which is serializable. The proxies would
have to keep track of whatever information they need to de-serialize
themselves (e.g. class name and constructor). It seems like this has
not been implemented, but do you think it is possible to do so?


That sounds cumbersome too :)

If the objects are in fact serializable, why can't you make 
them Serializable?


As I am learning AspectJ lately I try to solve every problem with it :)

it turns out you could weave DTOs you have no control over to implement 
Serializable interface:


public aspect SerializerImplementer {
declare parents: ProductDTO implements Serializable;
declare parents: ContractorDTO implements Serializable;
declare parents: InvoiceDTO implements Serializable;
}

You can do it once and have no problem with it ever again...

--
Leszek Gawron

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



Re: Uppercasing inputs

2009-03-06 Thread Leszek Gawron

taha siddiqi wrote:

Thanks!!( everyone MADE a joke and I BECAME one )


I'm sorry if you felt offended. It wasn't personal. Maybe my expression 
was not exact enough. After all I have used your proposal (modify 
Strings directly in domain model). What I didn't like is the requirement 
to change every set*( String value ) so I used AspectJ for that (which 
is probably a total overkill).


My regards
    lg
--
Leszek Gawron

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



Re: Equal InputValidator

2009-03-06 Thread Leszek Gawron

Peter Thomas wrote:

On Thu, Mar 5, 2009 at 11:13 PM, SrinivasaRaju Ch <
srinivas.r...@sifycorp.com> wrote:


Hi,

How to use Equal InputValidator in wicket  can any one give small example
on it.



see line #30

http://code.google.com/p/perfbench/source/browse/trunk/perfbench/wicket-jpa/src/main/java/wicketjpa/wicket/PasswordPage.java#30

This particular example is for EqualPasswordInputValidator on 2
PasswordTextField instances - you can try EqualInputValidator on 2 TextField
instances.


I recently found out there is Google Code Search in Google Labs. Saves 
me a lot of trouble:


http://www.google.com/codesearch?q=EqualInputValidator&hl=en&btnG=Search+Code

--
Leszek Gawron

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



Re: localization and session expiration

2009-03-06 Thread Leszek Gawron

Anton Veretennikov wrote:

May be cookie?


You can also try to extract the locale used by user in the browser from 
request header:



http://www.acegisecurity.org/guide/springsecurity.html#concurrent-sessions

GET /guide/springsecurity.html HTTP/1.1
Host: www.acegisecurity.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) 
Gecko/2009011913 Firefox/3.0.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pl,en;q=0.7,en-us;q=0.3

   ^

Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.acooke.org/cute/SessionLim0.html
If-Modified-Since: Tue, 15 Apr 2008 17:18:26 GMT
If-None-Match: "28002-5ba09-44aec96961c80"
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified
Date: Fri, 06 Mar 2009 11:52:59 GMT
Server: Apache/2.2.8 (EL)
Connection: close
Etag: "28002-5ba09-44aec96961c80"


Spring can resolve locale for you in a flexible manner:

http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/LocaleResolver.html

in your case:

http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.html

To integrate wicket with spring in this context override 
WebApplication.newSession:


@Override
public Session newSession( Request request, Response response ) {
return new WebSession( request ) {
@Override
public Locale getLocale() {
return LocaleContextHolder.getLocale();
}
    };
}


--
Leszek Gawron

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



Re: Only one session for logged user.

2009-03-06 Thread Leszek Gawron

Martin Bednář wrote:

Hello,

In our application I must guarantee that user is logged only once to the
application.
I have the following problem.

1,User logged to aplication, create session1
2,User browser crased, but session1 is still alive for next 30minutes
(session expiration time is 30minutes).
3,User open new browser and login to application (session2 is created).

And in point 3 I need close session1 before I log user in.

I hold userId in user session, but I don't know how to iterate over all
sessions and check if another session for same user is here.

Any advice ?


Have a look at how Acegi Security handles concurrent sessions management:

http://www.acegisecurity.org/guide/springsecurity.html#concurrent-sessions

hth

--
Leszek Gawron

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



Re: Uppercasing inputs

2009-03-06 Thread Leszek Gawron
I've been out for one day. I come back and see a thread with 38 
messages. That's crazy !:)


jWeekend wrote:

Leszek,

Thank you asking such a deep question ;-)
We may not all agree, but in the end, at least you have been offered around
87 well-intentioned solutions you can ask your customer to choose from; that
will teach them to request such complex features and fuctionality!


I was really blown by the amount of approaches you all presented. Thank 
you for all of them.


Some answers:

1. Dave wrote:

A slightly different approach: I would talk with the customer again, because 
this is a really stupid (excusez le mot) requirement. I hope you understand 
their motivation, possibly some legacy system that depends on uppercase 
information? Maybe the problem can be shifted to that legacy system that 
uppercases all data read from the database?


I thought so too but actually it's not that stupid after all. The 
customer has to enter A LOT of names, addresses etc. It speeds things up 
not to have to think about Proper Word Capitalization. Anything you type 
in always looks good.


2. I wanted to go with most non invasive way to do it. That is why I like:


public class UpperCaseBehavior extends AttributeAppender
{
   private static final long serialVersionUID = 1L;

   public UpperCaseBehavior()
   {
   super("style", new Model("text-transform: uppercase"), ";");
   }

   @Override
   public void bind(Component component)
   {
   super.bind(component);
   component.add(new AttributeAppender(
   "onkeyup", new Model("this.value = this.value.toUpperCase()"), 
";"));
   }
}



especially used with some nasty logic that would apply the behavior to 
every string field.


This is why I find this:


public void setFoo(String foo) {
  this.foo = foo == null ? null : foo.toUpperCase();
}


really ugly. Remember that I have to apply this for 99% of my domain model.

3. Igor, will this work:

class uppercasetextfield extends textfield {
public void updatemodel()
{
  final String str=getconvertedinput();
  setdefaultmodelobject((str==null)?null:str.touppercase());
}
}


If the form model is a loadable detachable model?


The solution I chose:


@UpperCased
@Entity
@Table(name = "usr")
@Inheritance(strategy = InheritanceType.JOINED)
public class User extends Persistent {
private boolean active  = true;
private String  code;

@NormalCased
private String  username;

@NormalCased
private String  password;
private String  firstName;
private String  lastName;
private Set roles   = new HashSet();
private String  mobilePhone;
private String  workPhone;
private String  colour;

> }

and:


public aspect Uppercaser {
pointcut setString( String value ) : ( ( set(String (@UpperCased *).* ) 
&& set(!...@normalcased String *.* ) )

|| set(@UpperCased String *.* ) )

&& args( value );

void around( String value ) : setString( value ) {
proceed( StringUtils.upperCase( value ) );
}
}


because:

1. I decided that the uppercasing should available for junit 
tests/command line tools etc.

2. It introduces the least changes into existing code.
3. It allows me to get rid of uppercasing just by recompiling the domain 
model library without the aspect (if ever my customer came back to 
"sanity").


It feels like I'm introducing way too complicated tool to solve an easy 
task (maybe judging by the number of the posts - not that easy after 
all), but what the hell...



Thank you for all posts. You are by no means one of the most helpful and 
vigorous OS community there is.


PS. I laughed almost to tears reading some posts. Very refreshing :)

--
Leszek Gawron 3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679
82148086513282306647093844609550582231725359408128
48111745028410270193852110555964462294895493038196
44288109756659334461284756482337867831652712019091
45648566923460348610454326648213393607260249141273
72458700660631558817488152092096282925409171536436
78925903600113305305488204665213841469519415116094
33057270365759591953092186117381932611793105118548
07446237996274956735188575272489122793818301194912
98336733624406566430860213949463952247371907021798
60943702770539217176293176752384674818467669405132
00056812714526356082778577134275778960917363717872
14684409012249534301465495853710507922796892589235
42019956112129021960864034418159813629774771309960
51870721134998372978049951059

Uppercasing inputs

2009-03-04 Thread Leszek Gawron

Hello,

one of my customers has this weird requirement that all data should be 
input/shown uppercase. I can easily add


input {
  text-transform: uppercase;
}

to my css rules, but this does not change the fact that data written 
into database will still be case sensitive.


How can I create a behavior for TextField so that the dat is uppercased 
before being written to the model?


my regards  

--
Leszek Gawron

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



Re: A doubt regarding "best-practices"

2009-02-05 Thread Leszek Gawron

Daniel Ferreira Castro wrote:

In lots of books about wicket I can see a Page implementation declaring a
Form as an inner class of the Page.
Of course that this is, in part, a personal preference.
I think, in my opinion, that the approach of declaring the Form as an inner
class makes the code more "dirty".  I mean, the Page class grows a lot and
by inspecting the code is hard to understand at a first glance the scope of
each entity and field.  So I prefer to declare the Form as a top class
instead inner class.

Is there any reccomendation that denies such thing?


It's probably a matter of preference and how big your form code actually is.



And also, regarding Forms yet...
If I declare a Form as a top class should I have a markup html for it
because this form will be treated as a component?


No, Form doesn't extend WebMarkupContainerWithAssociatedMarkup.

--
Leszek Gawron

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



Re: DataTable queries data provider for record count TWICE

2009-02-04 Thread Leszek Gawron

Igor Vaynberg wrote:

please open a bug report in jira.


your commit to NavigationToolbar.java (rev 739663) fixed the problem I 
had. Thank you!


--
Leszek Gawron

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



Re: DataTable queries data provider for record count TWICE

2009-01-31 Thread Leszek Gawron

Leszek Gawron wrote:
I lately switched to wicket 1.4. Suddenly my database gets hit 3 times: 
twice for size and once for actual data.


It gets even worse: one size() query gets executed even BEFORE new 
filter form values get propagated to filter model:


If I enter some search criteria into datatable's filter form this gets 
executed:



Hibernate: select count(*) as y0_ from patient this_
Hibernate: select count(*) as y0_ from patient this_ where 
lower(this_.firstname) like ?
Hibernate: select this_.id as id7_4_, this_.address_apartment as address2_7_4_, 
this_.address_building as address3_7_4_, this_.address_city as address4_7_4_, 
this_.address_postalcode as address5_7_4_, this_.address_street as 
address6_7_4_, this_.birthdate as birthdate7_4_, this_.birthplace as 
birthplace7_4_, this_.bloodgroup as bloodgroup7_4_, this_.company_id as 
company31_7_4_, this_.fathersname as fathers10_7_4_, this_.firstname as 
firstname7_4_, this_.height as height7_4_, this_.identitynumber as 
identit13_7_4_, this_.identitytype as identit14_7_4_, this_.insurancenumber as 
insuran15_7_4_, this_.insurancetype as insuran16_7_4_, this_.lastname as 
lastname7_4_, this_.mothersname as mothers18_7_4_, this_.nfz_id as nfz32_7_4_, 
this_.nip as nip7_4_, this_.payer_id as payer33_7_4_, this_.pesel as pesel7_4_, 
this_.phonenumber as phonenu21_7_4_, this_.profession as profession7_4_, 
this_.secondname as secondname7_4_, this_.sex as sex7_4_, this_.supervisor_id 
as supervisor34_7_4_

, this_.temporaryaddress_apartment as tempora25_7_4_, 
this_.temporaryaddress_building as tempora26_7_4_, this_.temporaryaddress_city 
as tempora27_7_4_, this_.temporaryaddress_postalcode as tempora28_7_4_, 
this_.temporaryaddress_street as tempora29_7_4_, this_.weight as weight7_4_, 
company2_.id as id8_0_, company2_.address_apartment as address2_8_0_, 
company2_.address_building as address3_8_0_, company2_.address_city as 
address4_8_0_, company2_.address_postalcode as address5_8_0_, 
company2_.address_street as address6_8_0_, company2_.extendedname as 
extended7_8_0_, company2_.name as name8_0_, company2_.nip as nip8_0_, 
company2_.phonenumber as phonenu10_8_0_, company2_.regon as regon8_0_, 
nfzdepartm3_.id as id4_1_, nfzdepartm3_.code as code4_1_, nfzdepartm3_.name as 
name4_1_, patient4_.id as id7_2_, patient4_.address_apartment as address2_7_2_, 
patient4_.address_building as address3_7_2_, patient4_.address_city as 
address4_7_2_, patient4_.address_postalcode as address5_7_2_, pat
ient4_.address_street as address6_7_2_, patient4_.birthdate as birthdate7_2_, 
patient4_.birthplace as birthplace7_2_, patient4_.bloodgroup as bloodgroup7_2_, 
patient4_.company_id as company31_7_2_, patient4_.fathersname as 
fathers10_7_2_, patient4_.firstname as firstname7_2_, patient4_.height as 
height7_2_, patient4_.identitynumber as identit13_7_2_, patient4_.identitytype 
as identit14_7_2_, patient4_.insurancenumber as insuran15_7_2_, 
patient4_.insurancetype as insuran16_7_2_, patient4_.lastname as lastname7_2_, 
patient4_.mothersname as mothers18_7_2_, patient4_.nfz_id as nfz32_7_2_, 
patient4_.nip as nip7_2_, patient4_.payer_id as payer33_7_2_, patient4_.pesel 
as pesel7_2_, patient4_.phonenumber as phonenu21_7_2_, patient4_.profession as 
profession7_2_, patient4_.secondname as secondname7_2_, patient4_.sex as 
sex7_2_, patient4_.supervisor_id as supervisor34_7_2_, 
patient4_.temporaryaddress_apartment as tempora25_7_2_, 
patient4_.temporaryaddress_building as tempora26_7_2_, pa
tient4_.temporaryaddress_city as tempora27_7_2_, 
patient4_.temporaryaddress_postalcode as tempora28_7_2_, 
patient4_.temporaryaddress_street as tempora29_7_2_, patient4_.weight as 
weight7_2_, patient5_.id as id7_3_, patient5_.address_apartment as 
address2_7_3_, patient5_.address_building as address3_7_3_, 
patient5_.address_city as address4_7_3_, patient5_.address_postalcode as 
address5_7_3_, patient5_.address_street as address6_7_3_, patient5_.birthdate 
as birthdate7_3_, patient5_.birthplace as birthplace7_3_, patient5_.bloodgroup 
as bloodgroup7_3_, patient5_.company_id as company31_7_3_, 
patient5_.fathersname as fathers10_7_3_, patient5_.firstname as firstname7_3_, 
patient5_.height as height7_3_, patient5_.identitynumber as identit13_7_3_, 
patient5_.identitytype as identit14_7_3_, patient5_.insurancenumber as 
insuran15_7_3_, patient5_.insurancetype as insuran16_7_3_, patient5_.lastname 
as lastname7_3_, patient5_.mothersname as mothers18_7_3_, patient5_.nfz_id as 
nfz32_7_3_, p
atient5_.nip as nip7_3_, patient5_.payer_id as payer33_7_3_, patient5_.pesel as 
pesel7_3_, patient5_.phonenumber as phonenu21_7_3_, patient5_.profession as 
profession7_3_, patient5_.secondname as secondname7_3_, patient5_.sex as 
sex7_3_, patient5_.supervisor_id as supervisor34_7_3_, 
patient5_.temporaryaddress_apartment as tempora25_7_3_, 
patient5_.temporaryaddress_building as tempora26_7_3_, 
patient5_.temporaryaddress_city as tempora27_7_3_, 
patient5_.temporaryaddress_postalco

DataTable queries data provider for record count TWICE

2009-01-31 Thread Leszek Gawron
  
ReferralsPage(Component).beforeRender() line: 1077  
ReferralsPage(Component).prepareForRender(boolean) line: 2202   
ReferralsPage(Component).prepareForRender() line: 2229  
ReferralsPage(Page).renderPage() line: 898  


I have checked with 1.3.x branch - IDataProvider.size() gets called only 
once.



--
Leszek Gawron

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



Clickable rows on DataTable - exceptions on refresh

2009-01-17 Thread Leszek Gawron

Hello,

I am trying to extend a data table to be able to respond to clicks 
anywhere on the row table:




public interface ClickHandler extends Serializable {
public void onClick( Item item );
}






public class CustomDataTable extends DataTable {
private FilterForm  filterForm;
private ISortableDataProvider  dataProvider;
private ClickHandler   rowClickHandler;

public ClickHandler getRowClickHandler() {
return rowClickHandler;
}

public void setRowClickHandler( ClickHandler rowClickHandler ) {
this.rowClickHandler = rowClickHandler;
}

public boolean isClickable() {
return rowClickHandler != null;
}

public CustomDataTable( String id, IColumn[] columns, 
ISortableDataProvider dataProvider, int rowsPerPage,
FilterForm filterForm ) 
{
super( id, columns, dataProvider, rowsPerPage );
this.dataProvider = dataProvider;
this.filterForm = filterForm;
createToolbars();
}

private void createToolbars() {
addTopToolbar( new NavigationToolbar( this ) );
if ( this.filterForm != null )
addTopToolbar( new FilterToolbar( this, filterForm, 
(IFilterStateLocator) dataProvider ) );

addTopToolbar( new HeadersToolbar( this, dataProvider ) );
addBottomToolbar( new NoRecordsToolbar( this ) );
addBottomToolbar( new NavigationToolbar( this ) );
}

public CustomDataTable( String id, IColumn[] columns, 
ISortableDataProvider dataProvider, int rowsPerPage ) {
this( id, columns, dataProvider, rowsPerPage, null );
}

@Override
protected Item newRowItem( String id, int index, IModel model ) {
return isClickable() ? new ClickableItem( id, index, model, 
rowClickHandler ) : new OddEvenItem( id,
index, model );
}
}




public class ClickableItem extends OddEvenItem implements ILinkListener {
private ClickHandler   handler;

public ClickableItem( String id, int index, IModel model, 
ClickHandler handler ) {
super( id, index, model );
this.handler = handler;
}

@Override
public void onLinkClicked() {
handler.onClick( this );
}

@Override
protected void onComponentTag( ComponentTag tag ) {
super.onComponentTag( tag );
tag.put("onclick",
String.format(  
"window.location.href='%1$s';return false",
urlFor( 
ILinkListener.INTERFACE ) ) );

String cls = "clickable";
String currentClass = tag.getAttributes().getString( "class" );
if ( currentClass != null )
cls += " " + currentClass;

tag.put("class",
cls );
}
}





Now the problem:

the links created for clicks on table row look like this:
http://localhost/app/properties/wicket:interface/:3:properties:filterForm:dataTable:rows:2::ILinkListener::/

while the url for "normal" Link is:
http://localhost/app/properties.3.2?wicket:interface=:3:properties:filterForm:dataTable:rows:3:cells:3:cell:edit:2:ILinkListener::

Clicking on the table row makes no redirect. Usually there is a redirect 
to: http://localhost/app/properties.3.2



When I hit refresh I get:

WicketMessage: unable to find component with path 
properties:filterForm:dataTable:rows:5 on stateless page [Page class = 
eu.org.squash.appcomponents.properties.example.PropertiesPage, id = 3, 
version = 5, ajax = 0] it could be that the component is inside a 
repeater make your component return false in getStatelessHint()


the row index "properties:filterForm:dataTable:rows:5" keeps advancing 
every time. There are only 2 rows in my test DataTable.


Could anyone comment? Maybe I am simply building the link for the row 
incorrectly.


--
Leszek Gawron

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



Very custom URL mapping

2008-11-19 Thread Leszek Gawron

Hello

I would like to achieve the following url space:
/ redirects to /form

/form - home page with a from
/form?something - followup of a home page's form

/resources/*.css
/resources/*.jpg - resources served from /resources

/ - SomePage with  in PageParamters


I know it would be a lot easier if I could do /somePage/ but 
unfortunately the requirement is different.


How can I achieve something like this without rewritng 90% of wicket's 
url matching logic ?


lg
--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



converter can not convert org.myproject.Something to a string

2008-05-05 Thread Leszek Gawron
I started getting these as soon as I have used latest wicket trunk in my 
project:



Caused by: java.lang.IllegalArgumentException: converter can not convert 
com.mobilebox.pfs.ranking.model.Sex to a string
at 
org.apache.wicket.markup.html.form.AbstractChoice.appendOptionHtml(AbstractChoice.java:392)
at 
org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:361)
at org.apache.wicket.Component.renderComponent(Component.java:2531)



This leads to:


protected void appendOptionHtml(AppendingStringBuffer buffer, E choice, 
int index,
String selected)
{
T objectValue = (T)renderer.getDisplayValue(choice);
Class objectClass = (Class)(objectValue == null ? null : 
objectValue.getClass());

String displayValue = "";
if (objectClass != null && objectClass != String.class)
{
final IConverter converter = 
this.getConverter(objectClass);

if (!converter.getClass().isAssignableFrom(objectClass))
throw new IllegalArgumentException("converter can 
not convert " +
objectClass.getName() + " to a string");

displayValue = converter.convertToString(objectValue, 
getLocale());
}


The check does not seem correct. How can converter class be ever 
assignable to an model object class? Or am I missing something?


--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: wicket-spring-annot 1.4-m1?

2008-04-30 Thread Leszek Gawron

James Carman wrote:

Is this gone now that 1.4 is JDK5+?  Is this stuff just bundled in
with wicket-spring?


yes

--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: WebRequestCycle and Open-session-in-view pattern

2008-04-28 Thread Leszek Gawron

Paolo Di Tommaso wrote:

Dear Wicket Gurus,

I'm implementing the Open-session-in-view pattern overriding the
onBeginRequest and onEndRequest method of a custom WebRequestCycle.

Is there any way to avoid to open a new hibernate session for non-view
request, for example resources request (css, javascript, images, etc)
served through the wicket application?

Basically I'm looking for a method to identify requests for static resources
that does not requires n open hibernate session.


As hibernate guys usually say the session is a lightweight object which 
does not cost much to create. Instantiating a session does not mean a 
database connection is fetched.


--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Wicket, Hibernate and Models

2008-03-13 Thread Leszek Gawron

Maurice Marrink wrote:

I believe refreshingview has better support for reusing items but in
our apps we hardly ever use refreshingview. both are suitable for use
with hibernate.

Maurice

On Thu, Mar 13, 2008 at 4:35 PM, carloc <[EMAIL PROTECTED]> wrote:

 What should I use when I am accessing hibernate?
 Should I use a ListView or should I use a refreshing view?\
 In the api it says to use refreshingview instead of using listview when
 using database collections
 what is better to use?



 carloc wrote:
 >
 > Hi everyone,
 >
 > I have been reading wicket in action recently and I have seen pitfalls of
 > hibernate section.
 > I was wondering about the stuff about hibernate and memory leaks due to
 > hibernate proxy objects maintaining a reference to the session with
 > them
 >
 >
 > Am I doing this wrong then?
 > @SpringBean
 > private UserService userService;
 >
 > add(new ListView("user", userService.findUsers() {
 > })
 >
 > is this wrong? I'm using it directly meaning it will be stored in the page
 > store right?
 >
 > should i be doing this instead?
 >
 > LoadableDetachableModel model = new LoadableDetachablemodel() {
 > Object load() {
 >return usrService.findUsers()
 >}
 >
 > }


please mind that you shouldn't create anonymous model classes as they 
keep the reference to the page/panel and you will fall into other memory 
issues.



--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: serving images from db - direct url access

2007-09-19 Thread Leszek Gawron

Johan Compagner wrote:

setCached causes wicket to send http cache headers. Resources it self
are cached in SharedResources. The resource itself is responsable what
is cached internally


what does it mean that Resource is cached in SharedResources?

In my case:

getSharedResources().add(   "snapshot",
new CameraSnapshotResource() );
mountSharedResource("snapshot",
new ResourceReference( "snapshot"
).getSharedResourceKey() );


there is a single resources but it produces different content basing on 
request parameters.


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: serving images from db - direct url access

2007-09-18 Thread Leszek Gawron

Johan Compagner wrote:

ahh ok that seems a bug can you report this?


It looks like this is the problem:


@Override
public IResourceStream getResourceStream() {
final ValueMap params = getParameters();

return new AbstractStringResourceStream() {
@Override
protected String getString() {
			// this wil work only with resource/id/1 
			CameraSnapshot current = cameraSnapshotService.findById( params.getLong( "id" ) );

return "";
}
};
}



@Override
public IResourceStream getResourceStream() {
return new AbstractStringResourceStream() {
@Override
protected String getString() {
			// this wil work only with resource?id=1 
			CameraSnapshot current = cameraSnapshotService.findById( getParameters().getLong( "id" ) );

return "";
        }
};
}


--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: serving images from db - direct url access

2007-09-17 Thread Leszek Gawron

Johan Compagner wrote:

ahh ok that seems a bug can you report this?


sure can,

one last question: there is a method set/getCached(). Does this tell the 
browser to cache the resource or does wicket cache it itself?


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: serving images from db - direct url access

2007-09-17 Thread Leszek Gawron

Johan Compagner wrote:

thats completely automatic.

in your Resource that you have mounted under /images/ when you get a request
to it
you just do: Resource.getParameters()


yes I did that. when requesting the resource like this:

http://host/app/resource?id=1
the id is visible in ValueMap

when requesting
http://host/app/resource/id/1

the id is NOT visible (although properly decoded by url coding strategy)

--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: serving images from db - direct url access

2007-09-17 Thread Leszek Gawron

Johan Compagner wrote:

look at WebApplication.mountSharedResources()
and RequestCycle.urlFor(final ResourceReference resourceReference, ValueMap
parameters)


I did the exact thing. Please see my others post about decoding request 
parameters.


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: serving images from db - direct url access

2007-09-17 Thread Leszek Gawron

David Bernard wrote:

Hi,

You can mount with a coding strategy in Application.init, something like 
.. (I do it for attachment)
mount(new MyMixedParamUrlCodingStrategy("/images", 
Page.class, new String[] { "id", "move" }) {

@Override
public IRequestTarget decode(RequestParameters 
requestParameters) {

try {
ValueMap params = 
decodeParameters(requestParameters.getPath().substring(getMountPath().length()), 
requestParameters.getParameters());

String id = params.getString("id");
String move = params.getString("move");
if (StringUtils.isNotBlank(id)) {
...
return new ResourceStreamRequestTarget(...);
}
return new 
WebErrorCodeResponseTarget(HttpServletResponse.SC_NOT_FOUND);


nice to know how to return errors :)


//return super.decode(requestParameters);
} catch (RuntimeException exc) {
throw exc;
} catch (Exception exc) {
throw new RuntimeException("wrap: " + 
exc.getMessage(), exc);

}
}
});


Thanks, I managed to do something like this:


getSharedResources().add(   "snapshot", new CameraSnapshotResource() );
mount( new SharedResourceRequestTargetUrlCodingStrategy( "/snapshot", new 
ResourceReference( "snapshot" ).getSharedResourceKey() ) );



public class CameraSnapshotResource extends DynamicWebResource {
@SpringBean
private CameraSnapshotService   cameraSnapshotService;

public CameraSnapshotResource() {
InjectorHolder.getInjector().inject( this );
}

@Override
protected ResourceState getResourceState() {
ValueMap parameters = getParameters();
Long id = parameters.getLong( "id" );
final CameraSnapshot snapshot = cameraSnapshotService.findById( 
id );

return new ResourceState() {
@Override
public String getContentType() {
return "image/jpeg";
}

@Override
public byte[] getData() {
try {
return snapshot.getData().getBytes( 1,

snapshot.getSize() );
} catch ( SQLException e ) {
throw new RuntimeException( "unable to fetch 
image data", e );
}
}
};
}
}


Now I have a problem:

http://host/wicketapp/snapshot?id=1 works
http://host/wicketapp/snapshot/id/1 does not (although when debugging I 
see parameters get decoded).


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



serving images from db - direct url access

2007-09-17 Thread Leszek Gawron

Hello,

I already know how to serve an image from database - dead easy. Thing is 
the image is a component. What i would like to achieve now is to have a 
very small image retrieving api:


http://host/mywicketapp/images/
http://host/mywicketapp/images//next
http://host/mywicketapp/images//previous
http://host/mywicketapp/images/latest

how do I mount a Resource at specified path?
how do I pass parameters to it ? (/next /previous)


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Localizer warnings

2007-09-12 Thread Leszek Gawron

I keep getting a lot of these after upgrading to 1.3-beta3

WARN  2007-09-12 12:49.41:532 [Localizer]  Tried to retrieve a localized 
string for a component that has not yet been added to the page. This can 
sometimes lead to an invalid or no localized resource returned. Make 
sure you are not calling Component#getString() inside your Component's 
constructor. Offending component: [Page class = 
com.mobilebox.indigo.web.configurator.page.WelcomePage, id = 7, version = 0]


I am not calling Component#getString() AFAIK, so what should I be 
looking for?


--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Model question

2007-09-11 Thread Leszek Gawron
Assuming eventModel is loadable detachable model sould I implement some 
marker interfaces in the following model?



private static class SystemWarningEventImagePathModel extends 
AbstractReadOnlyModel {
private IModel  eventModel;

public SystemWarningEventImagePathModel( IModel eventModel ) {
this.eventModel = eventModel;
}

@Override
public Object getObject() {
SystemWarningEvent event = (SystemWarningEvent) 
eventModel.getObject();
return event.isReadFlag() ? "img/mobile/event_read.png" : 
"img/mobile/event_new.png";
}
}



There are a number to take into account: IWrapModel, IChainingModel. 
Please advise.


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how to indicate a model changed when item has been removed?

2007-08-16 Thread Leszek Gawron
(Thermometer) getModelObject() 
);
}
} );
item.add( new ThermometerSensorPanel( 
"lowLevelSensorPanel", new PropertyModel( item.getModel(),
"lowLevelSensor" ), new 
ResourceModel( "lowLevelActions" ) ) );
item.add( new ThermometerSensorPanel( 
"highLevelSensorPanel", new PropertyModel( item.getModel(),
"highLevelSensor" ), new 
ResourceModel( "highLevelActions" ) ) );
}
} );
}
}



public class ActionsPanel extends Panel {
public ActionsPanel( String id, IModel model, IModel captionModel, 
final ActionHandler handler ) {
super( id, model );
add( new Label( "caption", captionModel ) );
add( new Link( "add", getModel() ) {
@Override
public void onClick() {
setResponsePage( new ActionPage( new 
ActionModel( (Long) null ), handler, getPage() ) );
}

@SuppressWarnings("unchecked")
@Override
public boolean isVisible() {
Set actions = (Set) 
getModelObject();
return actions.size() < 
ActionListSerializer.MAX_PER_PAGE_ACTION_COUNT;
}

} );

add( new RefreshingView( "list", getModel() ) {
@SuppressWarnings("unchecked")
@Override
protected Iterator getItemModels() {
Set actions = (Set) 
getModelObject();
return new ModelIteratorAdapter( 
actions.iterator() ) {
@Override
protected IModel model( Object object ) 
{
return new ActionModel( 
(Action) object );
}
};
}

@Override
protected void populateItem( Item item ) {
item.add( new Label( "name", new PropertyModel( 
item.getModel(), "actionDefinition.name" ) ) );
item.add( new Link( "delete", item.getModel() ) 
{
@Override
public void onClick() {
handler.delete( (Action) 
getModelObject() );
}
} );
}
} );
}
}



The model looks like this:

unitconfig -> thermometers
each thermometer is being wrapped with loadable detachable thermometer 
model which holds its   id


thermometer -> lowlevelsensor

lowlevelsensor -> actions

each action wrapped with loadable detachable action model

everything is based on property models apart from building refreshing 
list elements which do not need parent model.


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how to indicate a model changed when item has been removed?

2007-08-16 Thread Leszek Gawron

Leszek Gawron wrote:

Igor,

Igor Vaynberg wrote:

sounds like you are caching the list inside model returned by new
PropertyModel( getModel(), "thermometers") getModel() there.


This is not the case. the thermometer is removed from parent entity and 
the parent itself is being persisted, so memory model is in sync with 
database.


If I remove child panels from list then everything works fine. If the 
list was cached as you suggest then even after removal the return page 
would show the removed thermometer, which it does not.



It looks like this:

- query for thermometers' list page
- RefreshingView.getItemModels() called
- show page
- click edit on some thermometer
- page with form shown
- click delete
- RefreshingView.getItemModels() !NOT! called
- exception in list child panel
  ThermometersPanel$ThermometerSensorPanel.isVisible

why isn't thermometers list refreshed first?


when I remove child panels this happens:
- query for thermometers' list page
- RefreshingView.getItemModels() called
- show page
- click edit on some thermometer
- page with form shown
- click delete
- RefreshingView.getItemModels() called
- page shown

--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how to indicate a model changed when item has been removed?

2007-08-16 Thread Leszek Gawron

Igor,

Igor Vaynberg wrote:

sounds like you are caching the list inside model returned by new
PropertyModel( getModel(), "thermometers") getModel() there.


This is not the case. the thermometer is removed from parent entity and 
the parent itself is being persisted, so memory model is in sync with 
database.


If I remove child panels from list then everything works fine. If the 
list was cached as you suggest then even after removal the return page 
would show the removed thermometer, which it does not.


--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how to indicate a model changed when item has been removed?

2007-08-14 Thread Leszek Gawron

Leszek Gawron wrote:

Hello,
let me outline a problem I have. If you won't get much from my ramblings 
I'll try to provide a simplified ready-to-run example:

a small follow up:

commenting out child panels:


add( new RefreshingView( "list", new PropertyModel( getModel(), 
"thermometers" ) ) {
@SuppressWarnings("unchecked")
@Override
protected Iterator getItemModels() {
System.out.println( "get item models called" );
Map thermometers = 
(Map) getModelObject();
return new ModelIteratorAdapter( 
thermometers.values().iterator() ) {
@Override
protected IModel model( Object obj ) {
return new ThermometerModel( 
(Thermometer) obj );
}
};
}

@Override
protected void populateItem( final Item item ) {
item.add( new Link( "edit", item.getModel() ) {
@Override
public void onClick() {
setResponsePage( new 
ThermometerPage( getModel(), getPage() ) );
}
}.add( new Label( "name", new PropertyModel( 
item.getModel(), "name" ) ) ) );
//  item.add( new ThermometerSensorPanel( 
"lowLevelSensorPanel", new PropertyModel( item.getModel(),
//  "lowLevelSensor" ), new 
ResourceModel( "lowLevelActions" ) ) );
//  item.add( new ThermometerSensorPanel( 
"highLevelSensorPanel", new PropertyModel( item.getModel(),
//  "highLevelSensor" ), new 
ResourceModel( "highLevelActions" ) ) );
}
} );


makes the list work as expected. I do not get it.

--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



how to indicate a model changed when item has been removed?

2007-08-14 Thread Leszek Gawron
ramework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
 at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
 at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
 at 
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
 at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
 at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy32.findThermometerById(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at 
org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:402)
 at org.apache.wicket.proxy.$Proxy43.findThermometerById(Unknown Source)
 at 
com.mobilebox.indigo.configurator.model.ThermometerModel.loadEntity(ThermometerModel.java:51)
 at 
com.mobilebox.indigo.configurator.model.ThermometerModel.loadEntity(ThermometerModel.java:1)
 at 
com.mobilebox.indigo.common.model.PersistentEntityModel.load(PersistentEntityModel.java:56)
 at 
com.mobilebox.indigo.common.model.PersistentEntityModel.load(PersistentEntityModel.java:1)
 at 
org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetachableModel.java:111)
 at 
org.apache.wicket.model.AbstractPropertyModel.getTarget(AbstractPropertyModel.java:186)
 at 
org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:107)
 at org.apache.wicket.Component.getModelObject(Component.java:1293)
 at 
com.mobilebox.indigo.configurator.panel.thermometer.ThermometersPanel$ThermometerSensorPanel.isVisible(ThermometersPanel.java:84)




the underlined panel is list item's child (see first code snippet)

which clearly mean the list of thermometers hasn't been updated and now 
one of thermometer models references an entity that does not exist anymore.


How can I inform the page I am returning to that it's model is no longer 
valid? Why doesn't the RefreshingView simply refresh itself from the model?


Please advise.

--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



replace panels with fade effect

2007-07-28 Thread Leszek Gawron
I'd like to create an ajax heavy application (no pages, all panels). 
When replacing panels during ajax event I would like the old panel to 
fade out and new one to fade in (or any kind of morph effect).


I've been trying to make use of wicket-scriptaculous module but without 
success.


please advise.
lg
--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DataTable: incorrect 'showing x to y of z'

2007-07-28 Thread Leszek Gawron
When I create a DataTable paging data by 25 entries the navigation 
toolbar displays:


showing 1 to 26 of 80
showing 26 to 51 of 80

while (IMO) it should:
showing 1 to 25 of 80
showing 26 to 50 of 80

wdyt?

--
Leszek Gawron

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]