on 03-25-2008 1:29 PM
Hi there,
I need to fill a dropdown by key with values from a RFC model.
The values are the function & the description as can be seen in table TB913. I've created a test-FM which retrieves the info from the table and puts it in a TABLES-parameter called table.
Now I've created a webdynpro application and imported the model. So far so good.
Then I implemented the doInit method for the custom controller. In the do-init the RFC data should be gathered.
testi = new Zjco_Temp_12_Input();
msgMnr = wdComponentAPI.getMessageManager();
try{
testi.execute();
testo = testi.getOutput();
this.wdThis.wdGetContext().nodeOutput().bind(testo);
}
catch(Exception e){
msgMnr.reportException(e.getMessage(),true);
}
Now I've also the following code, which I implemented in method onActionSelected (event Selected (just to see what happens)):
IContextElement contextElement = wdContext.currentContextElement();
IWDNodeInfo nodeInfo = wdContext.getNodeInfo();
IWDAttributeInfo pftAttributeInfo = nodeInfo.getAttribute(wdContext.currentTableElement().BEZ30);
IModifiableSimpleValueSet dropValueSet = pftAttributeInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
String paFktTxt=null;
// Gives the Size of the List, which is coming from Model
int nodeLength = wdContext.nodeTable().size();
for (int i = 0; i < nodeLength; i++) {
// Gives the Value, Which you want to show in Drop Down List Box.. Change it according to your need.
paFktTxt = String.valueOf(((IPrivateTestView.ITableElement)(wdContext.nodeTable().getElementAt(i))).getBez30());
dropValueSet.put(paFktTxt, paFktTxt);
When I click on the dropdown (which is not yet filled), I get a NullPointerException. I think this is because the info isn't bound to the dropdown itself. Could this be? If yes, how should I proceed?
Could someone help me on the way?
Context structure for custom controller & view:
Output (model node)
Table (node)
Bez30
Client
Pafkt
Spras
Best regards
Allan
Edited by: Allan Duinslaeger on Mar 25, 2008 2:30 PM
Hi Allan
Please have a look at the following thread on how to implement a dropdown in a WebDynpro application:
And yes since you haven't bound any context attribute to your dropdown ui element you get a nullpointerexception.
Regards
Göran
Edited by: Göran Westin on Mar 25, 2008 3:41 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Armin!
That was very useful. But now I have a final question.
In my BAPI I have two exporting parameters, function and functionname, which are filled together with the table I talked about earlier.
I reimported the model and changed the contexts accordingly. Now I want to set a selected value via wdDoInit based on the values of function and functionname [these values exist in the dropdown].
The dropdown is based on bez30 [functionname].
I tried this by coding the next statements in wdDoInit, but this only changes the first line in the dropdown to the value of functionname. How to set the selected line to the passed value?
String function = (String)wdContext.nodeOutputv().currentOutputvElement().getFunction();
msgMngr.reportSuccess("Function= " + function);
//wdContext.currentTableElement().setPafkt(wdContext.nodeOutputv().currentOutputvElement().getFunction());
wdContext.currentTableElement().setBez30(wdContext.nodeOutputv().currentOutputvElement().getFunctionname());
Thanks!
Regards
Allan
Hi there,
Thanks, but that's not the problem..
The problem is that when I execute the code (see my last post), that instead of showing the right line in the dropdown, the values of the first line are replaced by the values which are passed through by the BAPI.
So I need to have a default selected line, based on the values of (function & functionname) returned by the BAPI.
Regards
Allan
Hi
if u want to set the dropdown on load of the view..
This code will set the country value as 'Australia' on loading of view and when we want to pass the value of Australia ( 'AU' ) in BAPI we will put a condition on that action.
e.g:
1. Just set the context Value on WDDoinit().
wdContext.currentContextElement().setCountry("Australia");
2. On action where we want to pass the Key of Australia in the BAPI...just put this code..
if(wdContext.currentContextElement().getCountry().equals("Australia")
{
Set country value as 'AU' in BAPI here.
}
else
set in bapi ( wdContext.currentContextElement().getCountry).
Regards
Puneet
Hi Puneet,
Thanks for the suggestions, but that is what I've done earlier & it doesn't solve the problem..
Let me try to make things more clearly:
Values in the dropdown:
-Biomedical Scientist
-Business Assistant
-Clinical Biologist
-Head of Department
-Engineer
-General Manager
-Hygienist
-Laboratory Director
-Marketing Manager
-Medical Assistant
-Medical Director
-Nurse
-PhD Student
-Head of Procurement
I get the values of function & functionname from the BAPI, I have to use these values for the selected line in the dropdown.
So if I get function 'PRH' and functionname 'Head of Procurement', I need to have that line selected/shown in the dropdown. (without the user having to do anything)
With my coding described in my former post I get the next result:
Values in the dropdown are then:
-Head of Procurement
-Business Assistant
-Clinical Biologist
-Head of Department
-Engineer
-General Manager
-Hygienist
-Laboratory Director
-Marketing Manager
-Medical Assistant
-Medical Director
-Nurse
-PhD Student
-Head of Procurement
=> Note that the first line in the dropdown has been changed instead of leaving everything as is, and just showing the 'Head of Procurement' line (which is on the last line in the dropdown).
I hope I made my problem clear. If not, just shout
Kind regards
Allan
Edited by: Allan Duinslaeger on Mar 26, 2008 12:19 PM
Add the following after the code that fills the drop-down list:
String function = wdContext.currentOutputvElement().getFunction();
for (int i = 0; i < wdContext.nodeTable().size(); ++i)
{
ITableElement item = wdContext.nodeTable().getTableElementAt(i);
if ( item.getPafkt().equals(function) )
{
wdContext.nodeTable().setLeadSelection(i);
break;
}
}
Armin
Thanks a lot Armin! Works like a charm!
Though, as in all dropdowns, there is an empty line. I know most users don't select that empty line, but if they do, there is a nullpointerexception.
I tried to avoid this by coding the next:
if (wdContext.nodeTable().currentTableElement().getBez30() != null){
String selectedKey = wdContext.currentTableElement().getPafkt();
msgMngr.reportSuccess("Selected key: " + selectedKey);
String selectedValue = wdContext.currentTableElement().getBez30();
msgMngr.reportSuccess("Selected value: " + selectedValue);
}
else{
msgMngr.reportException("You picked an empty value!", true);
}
But this doesn't work. Any idea how this is possible?
Edited by: Allan Duinslaeger on Mar 26, 2008 1:12 PM
Hi Allan,
Send the complete stack trace, better if u get the trace from the server log, otherwise not possible to find the problem.
regards
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sumit,
here it is.
java.lang.NullPointerException
at test.dropdown.TestView.onActionSelected(TestView.java:169)
at test.dropdown.wdp.InternalTestView.wdInvokeEventHandler(InternalTestView.java:159)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:313)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:759)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:712)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:261)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.