![web dynpro java basics web dynpro java basics](https://www.lifewire.com/thmb/aJFFWPD2uS7zpjQJepj-ZCBiZZk=/1711x1121/filters:fill(auto,1)/iStock_19988656_MEDIUM-58b746733df78c060e1f9625.jpg)
For example for my local project (LoggingTest) with application TestApp I’ll use (remember to use your port number and log to the Portal first ): Fast way for running Web dynpro application is to use dispatcher via url address. ** Hook method called to initialize controller.
Web dynpro java basics code#
WdContext.currentContextElement().setFinishedStatus("doWork we must ensure that our method with trace message will be called so add code to wDoInit method of TestCompView (each time when view will be initiated our message will be emitted). * We want to print messages with any severity */ So assuming you want to print some info message, you’ll must add a code like this: javadoc:doWork() Use simple method for severity of your message – debugT(String), infoT(String), pathT(String), errorT(String) and so on – for each severity type you have method with name severityT(String).First thing is to set effective severity of your logger (default is none, so no messages will be printed).Now let’s add some trace messages in doWork method. This code registers a new destination for our Location but doesn’t remove any other destinations! So in our case messages will be written to default trace and our new trace file. } catch (UnsupportedEncodingException e) we’re doing – for our location (logger) we’re adding new file log with specified path and name, encoding, limited to 1000000 bytes, with count set to 1 (so there will be only one file) and lastly we’re setting a TraceFormater which (default) prints messages in format: date location thread severity message. So, we’ve got our Location object, but must add a new FileLog to it. On the implementation of the TestComp scroll down to the bottom with lines others we can add our custom code for log initialization: others We will hardcode log configuration in code – this is only for learning purposes! More about external log configuration in next parts.
![web dynpro java basics web dynpro java basics](https://i.pinimg.com/originals/fb/b8/54/fbb8544e4ce4c47e6da2adaafbe51839.png)
This is because default trace files have a lot stuff that don’t interest us – we just want to watch our messages. We will use this Location, but we want to have separte file four our messages. This Location object logs messages to default traces file. Look in the code right after public class TestComp… statement – you’ll find a static variable for Location object. Ok, switch to the impelmentation tab for component controller in NWDS. Stupid and simple, but all we want is to add some useful code for logging. When doWork finishes processing, it will set it’s value and display it in view. This attribute is mapped to view and binded to TextView. All these things I putted in package . In component controller I added one method doWork and one context attribute finishedStatus (type string). I created simple Web Dynpro project ( LoggingTest) in NWDS with one component ( TestComp), one view ( TestCompView), one window and one app to run my component. In Netweaver’s terms, this article is about tracing. So, in the title of this weblog I used “logging” in the meaning “writing some usefull information to file or console” :). Tracing is for developers and support staff – trace messages contain program flow and are emitted by Location objects, which refer to certain point in a coding (Location is identified by package/class or function name). and are shared between multiple applications. Categories corresponds to administration task areas, for example /System /System/Database etc. Logging is mainly for administrators and log messages are emitted by Category objects.