thoughts on mvc and wd4a observations
Post on 13-Apr-2018
214 Views
Preview:
TRANSCRIPT
-
7/27/2019 Thoughts on MVC and WD4A Observations
1/6
Web Dynpro for ABAP Thoughts on MVC and WD4AObservationsMatt HardingBusiness CardCopany! Aurora "nergy
Posted on May# $$% $&&' (&!)* AM in ABAP%Web Dynpro
+ntrodu,tion
I'm a long time ABAPer (amongst other things) who also got involved in Web Dynpro
for JAA early on! "here were a few interesting feat#res and stability iss#es in the past$
b#t the whole approa%h for WD&J was pretty straightforward and aligned to prettywell!
However, when it came to transferring my understanding of WD4J to WD4A, I was a little confused at first as theWindow Controller and assistance class threw me. I had previously developed uite a few smaller WD4A apps,
however, recently I had the chance to developer a larger scale development which reuired componentdevelopment and leveraging all the features of We! Dynpro and came away with a few thoughts around how "#Cis esta!lished and potentially a pattern for !uilding WD4A applications.
-irst for the observations!
$he Assistance Class seems to !e a much !etter glo!al data storage location than the conte%t or local
varia!les withina controller &assuming they don't need to !e mapped through a conte%t(. )ot to mention, the
performance is supposedly much !etter &according to *A+ help(
$he Window Controller seems to own things much more than the Component Controller maing me
wonder whether the Component Controller could -ust !e wrapped into the Window Controller. i.e. $he Component
Controller can't navigate !ut it can tell the window controller to navigate. All the Component Controller seems
good for is interfacing and Conte%t Definitions.
It's funny how the Window in!ound plug hides its parameters &that would !e passed via the /01( within
the code section where on all other plugs on views, it's there in the definition screen &that one hurt me one day(.
All the tutorials out there have views navigating to other views which from an "#C pattern seems strange
unless you want to throw the #iew Controller in as a real controller &I don't typically( 2$o get around this, the
Component Controller can tell the Window Controller to fire plugs provided you include it as a reference in the
Component Controller.
It's ind of annoying that if you want to reuse one interfacing component in another component multiple
times, that the node structure can't really !e more than 3 deep as otherwise you need to map to new nodes within
the Component Controller. i.e. $he underlying code maes the )ode )ame specific, henceif you had )D53 and
)D56 and mapped an interface node to each )D5 !ut the node you were mapping had child nodes you wouldneed to map these separately &or something lie this(.
WDDI)I$ of the component controller is correctly called prior to the Window D57A/1$ plug, !ut this
means if you have parameters passed within a /01 you cannot initialise much in WDDI)I$. &solution is to call
an initialise method from the default plug on the Component Controller(
*u!scri!e
+rint
+ermalin
http://weblogs.sdn.sap.com/pub/u/35583http://www.sdn.sap.com/irj/scn/bc?u=9g7UM6qKyPE%2FLXwxopOn1w%3D%3Dhttp://weblogs.sdn.sap.com/weblogs/topic/29http://weblogs.sdn.sap.com/weblogs/topic/29http://weblogs.sdn.sap.com/weblogs/topic/43http://weblogs.sdn.sap.com/weblogs/topic/43http://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0&x-mimetype=application%2Frdf%2Bxmlhttp://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0&x-mimetype=application%2Frdf%2Bxmlhttp://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14407http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14407http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14407http://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0&x-mimetype=application%2Frdf%2Bxmlhttp://weblogs.sdn.sap.com/pub/u/35583http://www.sdn.sap.com/irj/scn/bc?u=9g7UM6qKyPE%2FLXwxopOn1w%3D%3Dhttp://weblogs.sdn.sap.com/weblogs/topic/29http://weblogs.sdn.sap.com/weblogs/topic/43http://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0&x-mimetype=application%2Frdf%2Bxmlhttp://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0&x-mimetype=application%2Frdf%2Bxmlhttp://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14407http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14407 -
7/27/2019 Thoughts on MVC and WD4A Observations
2/6
.o /hat0s this a11 about MVC2
Well my understanding of "#C is that the "odel is separate from the #iew, and the controller controls what data isretrieved from the "odel plus what view to display and what model data to pass to the #iew.
*o first I was thrown !y the fact that WDDoInit is called without any application conte%t information e%cept sy8uname that's running the application &as per my last point a!ove(. *o this got me to thining97or a component
that is not going to !e interfacing to another component, the Window Controller is actually more powerful than theComponent Controller. )ow !ecause I have the WD4J !acground,I'm going to assume that I've missed the pointsomewhere, and I'm still going to focus on the Component Controller !eing my main controller.
/nfortunately, from an "#C perspective, the controller is more than what the Component Controller can do as Icannot navigate directly from it to a different #iew. I could fire an event and asynchronously tell a view to fire aplug &which is not a good idea( pass parameters !ac from methods called !y the #iew &also not great( or I couldcall a method on the Window Controller to fire a plug.
If I do the latter$ I wo#ld %onsider the omponent ontroller and Window ontroller as
one (A perfe%t mat%h made in Waldorf)!
o what does this loo* li*e+
WDD,I-I" of omponent ontroller . Initialises anything global loo*ing that re/#iresinitialisation!
tart pl#g of Windows ontroller . "his %alls method on the omponent ontroller to
initialise the model data and navigate appropriately!
All navigation gets initiated by the omponent ontroller by %alling an appropriatelydefined Window ontroller whi%h fires its own o#tbo#nd pl#g to %hange views! -ote .
"here will be e0%eptions to this espe%ially if yo# 1#st want a basi% navigation from one
view to another li*e in a tab %ontrol or something b#t in this s%enario$ I wo#ld %onsider
the iew ontroller as a mini %ontroller /#ite %apable of performing these types of tas*s!
ain %onte0t is all stored in the omponent ontroller! "he Window ontroller 1#st
handles navigation and entry points to the appli%ation!
Anyway$ thats the gist of it! Im really hoping for someone from AP ("homas perhaps
2 hint hint 2 ongrat#lations on the birth of 3yan "homas J#ng again) to %ond#%t a 4bestpra%ti%e patterns5 style presentation %overing the best 4typi%al5 approa%h to things li*e
larger WD&A appli%ations$ b#t this is my short version of it for now that Id love to hear
from others how they maintain the pattern within WD&A!
"han*s all who got this far and hopef#lly see yo# at D- Day in Brisbane ne0t month or
at "e%h 6d Phoeni0!
att
Matt Hardingis Manager of Architecture at Aurora Energy who's passion is to design simple, intuitive and visuallyappealing solutions addressing functionality gaps.
Add to:del.icio.us; Digg;0eddit
http://weblogs.sdn.sap.com/pub/u/35583http://weblogs.sdn.sap.com/pub/u/35583http://del.icio.us/post?url=http://weblogs.sdn.sap.com/pub/wlg/14407&title=Web%20Dynpro%20for%20ABAP%20%E2%80%93%20Thoughts%20on%20MVC%20and%20WD4A%20Observationshttp://del.icio.us/post?url=http://weblogs.sdn.sap.com/pub/wlg/14407&title=Web%20Dynpro%20for%20ABAP%20%E2%80%93%20Thoughts%20on%20MVC%20and%20WD4A%20Observationshttp://digg.com/submit?phase=2&url=http://weblogs.sdn.sap.com/pub/wlg/14407http://digg.com/submit?phase=2&url=http://weblogs.sdn.sap.com/pub/wlg/14407http://reddit.com/submit?url=http://weblogs.sdn.sap.com/pub/wlg/14407&title=Web%20Dynpro%20for%20ABAP%20%E2%80%93%20Thoughts%20on%20MVC%20and%20WD4A%20Observationshttp://reddit.com/submit?url=http://weblogs.sdn.sap.com/pub/wlg/14407&title=Web%20Dynpro%20for%20ABAP%20%E2%80%93%20Thoughts%20on%20MVC%20and%20WD4A%20Observationshttp://weblogs.sdn.sap.com/pub/u/35583http://del.icio.us/post?url=http://weblogs.sdn.sap.com/pub/wlg/14407&title=Web%20Dynpro%20for%20ABAP%20%E2%80%93%20Thoughts%20on%20MVC%20and%20WD4A%20Observationshttp://digg.com/submit?phase=2&url=http://weblogs.sdn.sap.com/pub/wlg/14407http://reddit.com/submit?url=http://weblogs.sdn.sap.com/pub/wlg/14407&title=Web%20Dynpro%20for%20ABAP%20%E2%80%93%20Thoughts%20on%20MVC%20and%20WD4A%20Observations -
7/27/2019 Thoughts on MVC and WD4A Observations
3/6
A + off the ar3 +s there a better /ay -eedba,3 is /e1,oe as +5 happy to be ,op1ete1y /rong forthe sa3e of 1earning6Coent on this /eb1og
*howing messages 3 through < of (.
I was lucy, !ecause you e%perienced the same pro!lem lie me.
Guote:
It's ind of annoying that if you want to reuse one interfacing component in another component multiple times, that
the node structure can't really !e more than 3 deep as otherwise you need to map to new nodes within the
Component Controller. i.e. $he underlying code maes the )ode )ame specific, henceif you had )D53 and
)D56 and mapped an interface node to each )D5 !ut the node you were mapping had child nodes you wouldneed to map these separately &or something lie this(.
We have to use a we! dynpro component multiple times in our target we! dynpro component. $he Conte%t of the
muliple used component is hierarchically structured lie this:
C)$5$
;
;8)D53
; ;
; ;8*/)D53
; ; ;
; ; ;8*/*/)D53
; ; ; ;
; ; ; ;8A$$0I/$5333
; ; ; ;8A$$0I/$5336
; ; ;8*/*/)D56
; ; ;8*/*/)D5?
; ; ;8A$$0I/$533
; ; ;8A$$0I/$536
; ;8A$$0I/$53
; ;8A$$0I/$56
; ;8A$$0I/$5?
It is not possi!le to map the conte%t node &)D53( of !oth used components in the target component. 0enamingis only allowed for the root node. ut there are still naming conflicts with the child nodes.
Also mapping each child node seperatly and renaming it doesnKt wor, !ecause We!Dynpro seems to have a !ug
in this case.
When changing the lead selection of the mapped )D53, it does not affect the data stored in the su!nodes. *o
in the su!nodes there is still the data !elonging to the old lead selection.
Do you now or have you found a solution for this pro!lemE Is it really not possi!le to use the same we! dynpro
component multiple times and mapping the hierarchically structed conte%tE
http://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_disc/&x-lr2=wlg/14407&page=http://weblogs.sdn.sap.com/pub/wlg/14407?page=last&x-showcontent=off#threadhttp://weblogs.sdn.sap.com/pub/wlg/14407?page=last&x-maxdepth=0#threadhttp://weblogs.sdn.sap.com/pub/wlg/14407?page=last&x-order=date#threadhttp://weblogs.sdn.sap.com/cs/user/view/cs_msg/49378http://www.sdn.sap.com/irj/scn/bc?u=A%2FrUmkI56p8%3Dhttp://www.sdn.sap.com/irj/scn/bc?u=A%2FrUmkI56p8%3Dhttp://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/49378&x-lr2=wlg/14407http://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/49378&x-lr2=wlg/14407http://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_disc/&x-lr2=wlg/14407&page=http://weblogs.sdn.sap.com/pub/wlg/14407?page=last&x-showcontent=off#threadhttp://weblogs.sdn.sap.com/pub/wlg/14407?page=last&x-maxdepth=0#threadhttp://weblogs.sdn.sap.com/pub/wlg/14407?page=last&x-order=date#threadhttp://weblogs.sdn.sap.com/cs/user/view/cs_msg/49378http://www.sdn.sap.com/irj/scn/bc?u=A%2FrUmkI56p8%3Dhttp://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/49378&x-lr2=wlg/14407 -
7/27/2019 Thoughts on MVC and WD4A Observations
4/6
I also opened a thread in sdn for it:
http:forums.sdn.sap.comthread.-spaEthreadIDF3466L44MtstartF?=
o "ultiple /sage
6==8?= =?:N4:6< "att Hardingusiness CardB0eply
Hi 7lorian,
/nfortunately, I didnKt do e%tensive investigation to try resolve this though it was o!vious the meta data used meant
thereKs no easy solution. I -ust went with a flat structure which was annoying !ut it did the -o!. "ay!e name your
flat structure in a hierarchical way to at least mae it reada!leE
Oood luc,
"att
1in to 7loor +lan "anager Developers Ouide
6== 6?:3=:46 "att Hardingusiness CardB0eply
Just thought IKd add the lin to the 7+" guide for completeness:https:www.sdn.sap.comir-scngoportalprtrootdocsli!raryuuid:?? "att Hardingusiness CardB0eply
It loos lie I may not !e too far off the mar !ased on everyoneKs comments and itKs great to get other peopleKs
approaches &which are all fairly similar(.
)ote 8 IKve -ust remem!ered the 7+" document that was pu!lished not long ago &which doesnKt come up in the
search( so IKll give that a read and see if that changes my thining.
"att
*eparation of Concerns
6==
-
7/27/2019 Thoughts on MVC and WD4A Observations
5/6
controller and can often remain empty. ut if nowledge a!out navigation and different layouts must !e
programmed, put that into the window controller.
Cheers,
$horsten
$here are many ways to adopt the "#C pattern ...
6==.= that is WDA !ased.
What I would add to your considerations is that the We! Dynpro WiQard is really very very powerful !ut
unfortunately it implements everything in the We! Dynpro Component itself &e.g new methods in custom
controllers, new conte%t node, new statements in local methods and so on( and pro!a!ly it's not so "#C oriented.
$he most important consideration is indeed related to 7+" 2 7loorplan "anager. It's the new and strategic way to
implement WDA. At the !eginning it's a !it comple% !ut it add new options in terms of fle%i!ility, modulariQation and
configuration.
Vou should try 7+" &availa!le since )W >.=3( and even if your considerations will !e still important, you should
reallocate them to the new a!straction layer.
http://weblogs.sdn.sap.com/cs/user/view/cs_msg/46299http://weblogs.sdn.sap.com/cs/user/view/cs_msg/46299http://www.sdn.sap.com/irj/scn/bc?u=%2BttRckr5tG3MQLezP6RwXg%3D%3Dhttp://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/46299&x-lr2=wlg/14407http://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/46299&x-lr2=wlg/14407http://weblogs.sdn.sap.com/cs/user/view/cs_msg/46262http://weblogs.sdn.sap.com/cs/user/view/cs_msg/46262http://www.sdn.sap.com/irj/scn/bc?u=FRPo6E0sE13DEFzyFzQahg%3D%3Dhttp://www.sdn.sap.com/irj/scn/bc?u=FRPo6E0sE13DEFzyFzQahg%3D%3Dhttp://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/46262&x-lr2=wlg/14407http://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/46262&x-lr2=wlg/14407http://weblogs.sdn.sap.com/cs/user/view/cs_msg/46299http://www.sdn.sap.com/irj/scn/bc?u=%2BttRckr5tG3MQLezP6RwXg%3D%3Dhttp://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/46299&x-lr2=wlg/14407http://weblogs.sdn.sap.com/cs/user/view/cs_msg/46262http://www.sdn.sap.com/irj/scn/bc?u=FRPo6E0sE13DEFzyFzQahg%3D%3Dhttp://weblogs.sdn.sap.com/cs/user/create/cs_msg?x-lr=cs_msg/46262&x-lr2=wlg/14407 -
7/27/2019 Thoughts on MVC and WD4A Observations
6/6
+ersonally, within the large WDA pro-ects IKm conducting, I instructed my team to implement as less code as
possi!le within WDC. Instead we define and implement the "D51s as classic AA+ Classes &*564( to
represent the usiness !-ects &Customer, Invoice,9( and we save into WD Assistance Class the instances of the
"D51s &AA+ Classes(. We specialiQe the "D51s via new Classes to add some functions dedicated to
We! Dynpro &e.g. conte%t management( or we implement specific methods into the assistance class &also for the
multi8language feature(. *o all the modules of the WDC &and even the su!components via shared Assistance
Classes ( access the "D51s via an attri!ute of the assistance class &e.g. wdassist8customer8getid& ((. In my
team, we accept to lose some interesting features of the WD WiQard to stay more aligned to "#C or to say !etter
we use the wiQard as a starting point and then we cutMpaste pieces of code auto generated code in the right
module of "D51.
*ome of the main !enefits are: the possi!ility to use powerful AA+ tools lie &*earch0eplace(, Code Inspector,
5asy $est from *564 of each method without going trough the whole application, where8used8list that within a
WDC wor with some restrictions.
*ergio
o $here are many ways to adopt the "#C pattern ...
6==
top related