Results 1 to 4 of 4

Thread: Create View dynamically?

  1. #1
    Join Date
    Jun 2006
    Posts
    14

    Default Create View dynamically?

    Can we create different instance of 'View' in runtime and fire it up on the page?


    The following code doesn't work properly, it will give me null pointer exception. Can anyone kind enough to correct me pls

    Code:
    DefaultViewDescriptor vdesciptor = new DefaultViewDescriptor();
    vdesciptor.setViewClass(MyView.class);   
    getActiveWindow().getPage().showView(vdesciptor);
    java.lang.NullPointerException
    at org.springframework.richclient.application.support .AbstractApplicationPage$1.test(AbstractApplicatio nPage.java:73)
    at org.springframework.core.closure.support.AbstractE lementGenerator$ObjectFinder.handle(AbstractElemen tGenerator.java:182)
    at org.springframework.core.closure.support.Block.cal l(Block.java:28)
    at org.springframework.core.closure.support.AbstractE lementGeneratorWorkflow.run(AbstractElementGenerat orWorkflow.java:26)
    at org.springframework.core.closure.support.AbstractE lementGenerator.findFirst(AbstractElementGenerator .java:74)
    at org.springframework.core.closure.support.AbstractE lementGenerator.findFirst(AbstractElementGenerator .java:69)
    at org.springframework.core.closure.support.Algorithm s.findFirst(Algorithms.java:125)
    at org.springframework.core.closure.support.Algorithm s.findFirst(Algorithms.java:113)
    at org.springframework.core.closure.support.Algorithm sAccessor.findFirst(AlgorithmsAccessor.java:35)
    at org.springframework.core.closure.support.AbstractC onstraint.findFirst(AbstractConstraint.java:51)
    at org.springframework.richclient.application.support .AbstractApplicationPage.findPageComponent(Abstrac tApplicationPage.java:77)
    at org.springframework.richclient.application.support .AbstractApplicationPage.showView(AbstractApplicat ionPage.java:168)

  2. #2
    Join Date
    May 2005
    Posts
    394

    Default

    I 've hacked it like this...

    public class XView ... {
    public XView() {
    // HACK to fit a view into a form
    DefaultViewDescriptor defaultViewDescriptor = new DefaultViewDescriptor();
    defaultViewDescriptor.setId(VIEW_ID);
    setDescriptor(defaultViewDescriptor);
    ...


    But Views and Forms should be retrievable from the application context at runtime and more interchangable

  3. #3
    Join Date
    Jun 2006
    Posts
    14

    Default

    if u set the descriptor inside the XView class, how can u show it up on the page? When you use getPage().showView(descriptor), it will complain "A view descriptor may only be set once". Is there any workaround? thanx
    Last edited by aktp; Jul 5th, 2006 at 09:54 AM.

  4. #4
    Join Date
    May 2005
    Posts
    394

    Default

    In my use case, I just wanted to add a View inside a Form (=ugly hack), so I did something like xView.getControl()
    The reason I wanted that in my use case was because I have a CrudView, which supports new/edit/delete on a domain object list and is injected with a CrudService.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •