Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [e4-dev] MPart.getContext() is null

a model object only gets a context once it is renderer which is not the
case for you.

You could e.g. push the value into the window or perspective context
which the part context will be derived from.

Tom

Am 20.02.12 17:40, schrieb Dimitar Georgiev:
> Hello,
> 
> For my demo app I want clicking a button on part 'a' to set part 'b' to
> visible (it is initially invisible).
> My part b relies on a domain object com.acme.SalesOrder so i have
>   @Inject public PartB(SalesOrder salesOrder) ...
> 
> I wondered how I should provide this domain object dependency. In the
> code responsible for making part 'b' visible, I did:
> 
> MPart partB= partService.findPart("com.acme.partb");
>         partB.getContext().set(SalesOrder.class, salesOrder);
> partService.showPart(checkoutPart, PartState.ACTIVATE);
> 
> --> java.lang.NullPointerException
>     at org.acme.Part1.checkoutRequested(Part1.java:268)
> 
> So, IEclipseContext was null for an MPart obtained thru the part
> service. On the other hand, I noticed the following idiom in most of the
> other MPart getters:
> 
> if(stuff==null) {
> initializeStuff();
> }
> return stuff;
> 
> So I was wondering whether this was a bug, or I am not using the
> platform correctly?
> Thanks in advance!
> 
> Regards, Dimitar
> 
> 
> 
>  
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> e4-dev mailing list
> e4-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/e4-dev


-- 
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl                 geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1   A-6020 innsbruck     fax      ++43 512 935833
http://www.BestSolution.at                      phone    ++43 512 935834


Back to the top