Hi everyone,

I want to let user to press "F5/refresh button", and the page will get the
latest info from the database and show to the user again without click
another link (like refresh link to setResponsePage()).
I have searched thru the mail list and find some info on the refresh button,
bookmarkablePageLink and detachableModels... however, I still cannot make it
work without doing the following:

Basically I have a table of rows (Files) and user can click the link to
enter FileDetail page.
=============FileDetail.java======================
public class FileDetail extends DataStorePage implements
DataStoreSecuredPage {

    public FileDetail(final DataStoreFile file) {

        this.setModel(new LoadableDataStoreFileModel(file));

        add(new Label("id", new AbstractReadOnlyModel() {
            public Object getObject(Component component) {
                return
((DataStoreFile)component.getParent().getModelObject()).getId();
            }
        }));

        add(new Label("status", new AbstractReadOnlyModel() {
            public Object getObject(Component component) {
                return
((DataStoreFile)component.getParent().getModelObject()).getStatus();
            }
        }));

        add(new Label("uniqueKey", new AbstractReadOnlyModel() {
            public Object getObject(Component component) {
                return
((DataStoreFile)component.getParent().getModelObject()).getUniqueKey();
            }
        }));
    }
}

=========LoadableDataStoreFileModel.java (I read Apress Pro Wicket and wrote
this java)================
public class LoadableDataStoreFileModel extends LoadableDetachableModel {

    private final Long id;

    public LoadableDataStoreFileModel(Long id) {
        super();
        this.id = id;
    }

    public LoadableDataStoreFileModel(DataStoreFile file) {
        this(file, file.getId());
    }

    public LoadableDataStoreFileModel(DataStoreFile file, Long id) {
        super(file);
        if (id == null || id == new Long(0)) {
            throw new IllegalArgumentException();
        }
        this.id = id;
    }

    protected Object load() {
        return getDelegate().getDataStoreFile(id);
    }

    private BusinessDelegate getDelegate() {
        return ((DataStoreWebApplication)Application.get()).getDelegate();
    }
}

is there any better way to do this? or the LoadableDataStoreFileModel can
perform like CompoundPropertyModel? I tried ICompoundProperty and no luck. I
don't want to have a bookmarkablePage also.

Thank you, this is my first post in this list, if there is anything wrong,
please tell me too.
Matthew Kwong
-- 
View this message in context: 
http://www.nabble.com/Question-about-LoadableDetachableModel-and-refresh-button-tf2933650.html#a8201987
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to