Announcement Announcement Module
Collapse
No announcement yet.
Create View dynamically? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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, 10:54 AM.

      Comment


      • #4
        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.

        Comment

        Working...
        X