NullPointerException on wdContext.nodeMyNode().getElementAt(i)
This is a strange one...
The following loop throws a NullPointerException :
<br>
int size = wdContext.nodeZoneList().size(); // size is 42...
for (int i = 0; i < size; i++)
// the following throws a NullPointerException when i == 0 !!
Object obj = wdContext.nodeZoneList().getElementAt(i);
Unless I'm missing something here, shouldn't getElementAt() return valid elements for i=0 to size-1 ??
Anyone with an explanation of what could cause the NullPointerException ?
On an unrelated note; can anyone tell me why my message gets surrounded by [ nobr ] and [ /nobr ] when I post ?
Hi,
Your statement
// the following throws a NullPointerException when i == 0 !!
Do you mean to say that it throws the error only when i=0 and give the expected results for all other values of i?. That's quite impossible.
Also, is the node named 'ZoneList' a model binded node? Is this a parent node in your WD context or is it a child node in your context. If this is a child node and if the singleton property is set to 'true', you may have to access this child node by the code as below
IWDNode nodeZoneList = parentNode.getChildNode("ZoneList",parentNode.getLeadSelection());
int size = nodeZoneList.size(); // size is 42...
for (int i = 0; i < size; i++)
// the following throws a NullPointerException when i == 0 !!
IWDNodeElement obj = nodeZoneList.getElementAt(i);
But still the wdContext.nodeZoneList().size() returning 42 and the very same wdContext.nodeZoneList() returning null inside the for loop is strange. Here exception is thrown because 'wdContext.nodeZoneList()' returns null; not because getElementAt(i) returns null. It doesn't matter what getElementAt(i) returns and exception won't be thrown for this returning null.
Kindly also check for the cardinality setting (collection and selection, both) of the node in the WD context.
Regards,
Sudeep
Similar Messages
-
Null Pointer Exception while reading inbox
Hi Experts
I am getting the Null Pointer Exception when I execute the following code. Can anybody please suggest where i am going wrong.
public void readInbox( )
//@@begin readInbox()
while (! wdContext.nodeEmail().isEmpty()) {
wdContext.nodeEmail().removeElement(wdContext.nodeEmail().getElementAt(0) );
wdContext.nodeEmail().invalidate();
Message[] message = new Message[1000];
IPublicEmailInteractiveFormComp.IEmailElement newEmailNodeElement;
//Set properties
// @TODO Enter your email server address here by replacing the text in angle brackets.
String host = "otemail.otegroup.com";
// @TODO Enter your email account here by replacing the text in angle brackets.
String username = "[email protected]";
// @TODO Enter your email account password here by replacing the text in angle brackets.
String password = "password";
Properties props = new Properties();
props.put("mail.smtp.host", host);
//Set Session
Session session = Session.getInstance(props, null);
//Set the store
try {
Store store = session.getStore("imap");
store.connect(host,username,password);
//Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
//Get Mails
message = folder.getMessages();
//Fill table with mails
for (int i = 0; i < message.length; i++)
if (message<i>.isSet(Flags.Flag.SEEN) == false)
if (message<i>.getSubject().equals("Travel Request Form"))
newEmailNodeElement = wdContext.createEmailElement();
newEmailNodeElement.setFrom(message<i>.getFrom()[0].toString());
newEmailNodeElement.setSubject(message<i>.getSubject());
newEmailNodeElement.setSentDate(message<i>.getSentDate().toString());
//Check for right Attachment
Object content = message<i>.getContent();
if ( content != null && content instanceof Multipart)
for (int j = 0 , n = ((Multipart)content).getCount(); j < n; j++)
Part part = ((Multipart)content).getBodyPart(j);
String disposition = part.getDisposition();
if ( disposition != null && (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE)))
if (part.getFileName().equals("TravelRequest.pdf"))
newEmailNodeElement.setAttachment(true);
newEmailNodeElement.setContentType(part.getContentType().toString());
InputStream is = part.getInputStream();
ByteArrayOutputStream bo = new ByteArrayOutputStream();
int c;
while ((c = is.read()) > -1) bo.write(c);
byte[] pdfSource = bo.toByteArray();
newEmailNodeElement.setPdfSource(pdfSource);
break;
else
newEmailNodeElement.setAttachment(false);
wdContext.nodeEmail().addElement(newEmailNodeElement);
//Close connection
folder.close(true);
store.close();
catch (MessagingException e)
wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());
e.printStackTrace();
catch (IOException e)
wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());
e.printStackTrace();
catch (NullPointerException e)
wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());
e.printStackTrace();
//@@end
Regards
AbdullahThe error was caused when the subject used to return null
-
Runtime error in DropDownByKey
Hi all,
In my appl,
This is the code inside my wdInit() of CustomeController:
Y_Ep_Demo_Get_Material_Input ip=new Y_Ep_Demo_Get_Material_Input();
wdContext.nodeY_Ep_Input().bind(ip);
IWDMessageManager manager= wdComponentAPI.getMessageManager();
IWDAttributeInfo aInfo = wdContext.getNodeInfo().getAttribute("Matnr");
<b>IModifiableSimpleValueSet
vSet=aInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValu
eSet();</b>
String matnum=null;
int nLen=wdContext.nodeY_Ep_Input().size();
for(int i=0;i<nLen;i++){
matnum=String.valueOf(((IPrivateSD_InsertCompView.IContextElement)(wdContext
.nodeY_Ep_Input().getElementAt(i))).getAttributeValue("Matnr"));
vSet.put("Matnr",matnum);
manager.reportSuccess("in For loop");
I am getting error at this line as NullPointerException.
I have created a Model node and done the necessary mapping to Model attr of my Bapi. In the properties of DropDownByKey->selectKey->mapped to context attr.
Please suggest me/let me the procedure to get values into DropDown list from R/3.
Thanks a lot in advance!Hi Satyajit,
Thanks for the inputs. This is the code in wdInit() of CustomeController:
Y_Ep_Demo_Material_Sd_View_Output op=new Y_Ep_Demo_Material_Sd_View_Output();
wdContext.nodeY_Ep_Input().bind(op);
IWDAttributeInfo aInfo=wdContext.nodeY_Ep_Input().getNodeInfo().getAttribute("Matnr_Out"); IModifiableSimpleValueSet vSet= aInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
String matnum=null;
int len=wdContext.nodeY_Ep_Input().size();
mgr.reportSuccess(""+len);
for(int i=0;i<len;i++){
matnum=String.valueOf(((IPublicSDI_Cust.IY_Ep_InputElement) (wdContext.nodeY_Ep_Input().getY_Ep_InputElementAt(i))).getMatnr_Out());
vSet.put("Matnr_Out",matnum);
where Y_Ep_Input is Context-Model Node and Matnr_Out is my attribute. That was bound as you said. This time I got null in DropDownlist. When I tried to print the size of list am getting 1 as output.
What went wromg, is my code correct.
Thanks a lot -
Access a value attribute under a value node
Hi guys,
Could you please help me on this one. I need to access value attributes that are under a value node?. I use the following codes and I always have the error "java.lang.NullPointerException ".
1) wdThis.wdGetContext().currentMyValueNodeElement().getMyAttribute();
2) wdContext.currentMyValueNodeElement().getMyAttribute();
Thanks in advance
FranckHEre is an example where I'm pulling a value from a value attribute where the Node is a table. "Ytdsl" is the actual value attribute name.
// Get the total from the last line of the table
String sx =
wdContext
.nodeChannelList()
.getElementAt((wdContext.nodeChannelList().size() - 1))
.getAttributeValue("Ytdsl")
.toString();
Regards,
Rich Heilman -
Hi Guys
I want to insert data from a Table( in a View ) to R3.. Though data is getting inserted but only one Row... I want all the Rows to be inserted.. Plz help...Hi,
In that read the table context elements one by one.
for(int i=0;i<wdCOntext.nodeTable().size();i++)
wdContext.nodeTable.getElementAt(i); //Read eleement
//Read the attributes by using Get wdContext.nodeTable.getElementAt(i).getAttributeValue("<<AtrtibuteName>>);
//Now set the Inputparameters to FM and execute
Regards, Anilkumar -
How get all rows of a table with a BAPI
Hi,
how is it possible to get more then one row by calling a BAPI from the WD. In my Application I need the rows of a Table coming from the r/3 System. How is it possible to get all the rows after the first call? What is the logic behind it? My purpose is also to create an own BAPI.
regards,
Sharam
nullHi,
If I understand, you don't want display the result into a Web Dynpro Table. If so, after the execution, the result of your request is stored into the context. Then you don't really need to transfert the data from your context to an Java Array.
But if you want to do it, here is the code :
guess your result node called
nodeResult
Vector myVector = new Vector();
for (int i = 0; i < wdContext.nodeResult().size(); i++){
myVector.put(wdContext.nodeResult().getElementAt(i));
I hope this will answer to your question.
Regards -
Hi,all
I have a problem with formatting date with SimpleDateFormat.
I need that the date will be of format dd/mm/yyyy hh:mm:ss
With date all is showing fine,I use dd/MM/yyyy ,but if I add
hh:mm:ss instead of right time I give 12:00:00.
What may be the problem?
Regards,
Michael
Message was edited by:
Michael BeilinHi Michael,
See this code to dipplay the date input field value.
Put the format you need.
Package
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Code:-
SimpleDateFormat smpdtFormat =new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String validFr="";
validFr = wdContext.nodeProductDate().getElementAt(0).getAttributeValue("Validfr").toString();
prodElem.setValidFrom(new Date(smpdtFormat.parse(validFr).getTime()));
Regards,
Mithu -
Paradigm Shift: the WDP Model & the Power to Bind
As a developer coming from an OO/java background, I recently started to study and use the Java Web Dynpro framework for creating enterprise portal applications.
Up to this point, I've developped 2 or 3 WDP projects - and in so doing, I've tried to reconciliate my java-influenced development methods with the SAP way of doing things. I'd say for the most part it was rather painless. I did, however, find a serious problem as far as I'm concerned in the way SAP has promoted the use of the java bean model importer.
<a href="https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/u/251697223">david Beisert</a> created this tool and presented it to the SDN community in 2004 in his <a href="/people/david.beisert/blog/2004/10/26/webdynpro-importing-java-classes-as-model The same year (don't know if it was before or after), SAP published '<a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1f5f3366-0401-0010-d6b0-e85a49e93a5c">Using EJBs in Web Dynpro Applications</a>'. Both of these works presented simplified examples of invoking remote functions on EJB backends (an add() function in the case of David Beisert's example, and a calculateBonus() function in the case of the SAP publication). Accordingly, they both recommended the use of the Command Bean pattern as an implementation strategy for their respective examples. Which I don't totally disagree with, in these particular circumstances. A simple execute() method is perfectly suitable if one needs to EXECUTE a remote function call - whether it be a calculate() method invoked on a EJB Session Bean or an RFC call made to some remote ABAP system.
Problem is, not everything in life is a function call ! To me, it makes very little sense to model everything as a command if it doesn't match your business model. The needs of your application should dictate the architecture of your model and not the other way around.
This unjustifiable fixation on the Command Bean pattern is probably to blame for the fact that very little up to this point seems to have been written on the subject of the power of the binding mecanism as a most powerful tool in the arsenal of the Web Dynpro developer.
What's this ?
Binding can make it possible to abstract away most of the nitty gritty context node navigation and manipulation logic and replace it with more intuitive and more developer-friendly model manipulation logic.
There was a time when programs that needed persistence were peppered with database calls and resultset manipulation logic. Hardly anyone codes like that anymore.. and with good reason. The abstraction power of Object Oriented technologies have made it possible to devise human friendly models that make it possible for developers to concentrate on business logic, and not have to waste time dealing with the low-level idiosyncrasies of database programming. Whether it be EJBs, JDO, Hibernate... whatever the flavour... most serious projects today utilize some sort of persistence framework and have little place for hand-coding database access logic.
I feel that the WD javabean model offers the same kind of abstraction possibilities to the Web Dynpro developer. If you see to it that your WD Context and javabean model(s) mirror each other adequately, the power of binding will make it possible for you to implement most of your processing directly on the model - while behind the scenes, your context and UI Elements stay magically synchronized with your user's actions:
+-------------+ +-------------------+ +--------------+ +------------+
| Model |<-bound-| Component Context |<-mapped-| View Context |<-bound-| UI Element |
+-------------+ +-------------------+ +--------------+ +------------+
o Context Root o Context Root
| |
ShoppingCartBean <---- +-o ShoppingCart Node <------ +-o ShoppingCart Node
{ | |
Collection items <---- +-o CartItems Node <--------- +-o CartItems Node <-- ItemsTable
{ | |
String code; <-------- +- Code <-------------------- +- Code <----------- CodeTextView
String descrip; <----- +- Description <------------- +- Description <---- DescTextView
Let's examine an example of this concept. I propose a simple but illustrative example consisting of a shopping cart application that presents the user with a collection of catalog items, and a shopping cart in which catalog items may arbitrarily be added and/or removed.
The Component and View contexts will be structured as follows:
o Context Root
|
+--o ProductCatalog (cardinality=1..1, singleton=true)
| |
| +--o CatalogItems (cardinality=0..n, singleton=true)
| |
| +-- Code
| +-- Description
|
+--o ShoppingCart (cardinality=1..1, singleton=true)
|
+--o ShoppingCartItems (cardinality=0..n, singleton=true)
|
+-- Code
+-- Description
Let's examine how a conventional Command Bean implementation of this component could be coded. Later on, I'll present a more object-oriented model-based approach. We can then compare the differences.
public class ProductCatalogCommandBean
// collection of catalog items
Collection items = new ArrayList();
public void execute_getItems()
// initialize catalog items collection
items = new ProductCatalogBusinessDelegate().getItems();
This command bean will serve as a model to which the ProductCatalog node will be bound. This happens in the supply function for that node in the component controller:
public supplyProductCatalog(IProductCatalogNode node, ...)
// create model
model = new ProductCatalogCommandBean();
// load items collection
model.execute_getItems();
// bind node to model
node.bind(model);
No supply function is needed for the ShoppingCart node, since it is empty in its initial state. Its contents will only change based on the user adding to or removing items from the cart. These operations are implemented by the following two event handlers in the view controller:
public void onActionAddItemsToCart()
// loop through catalog items
for (int i = 0; i < wdContext.nodeCatalogItems().size(); i++)
// current catalog item selected ?
if (wdContext.nodeCatalogItems().isMultiSelected(i))
// get current selected catalog item
ICatalogItemsElement catalogItem = wdContext.nodeCatalogItems().getElementAt(i);
// create new element for ShoppingCartItem node
IShoppingCartItemsElement cartItem = wdContext.createShoppingCartItemsElement();
// initialize cart item with catalog item
cartItem.setCode (catalogItem.getCode());
cartItem.setDescription(catalogItem.getDescription());
// add item to shopping cart
wdContext.nodeShoppingCartItems().addElement(cartItem);
public void onActionRemoveItemsFromCart()
// loop through cart items
for (int i = 0; i < wdContext.nodeShoppingCartItems().size();)
// current shopping cart item selected ?
if (wdContext.nodeShoppingCartItems().isMultiSelected(i))
// get current selected item
IShoppingCartItemsElement item = wdContext.nodeShoppingCartItems().getElementAt(i);
// remove item from collection
wdContext.nodeShoppingCartItems().removeElement(item);
else
// process next element
i++;
From what I understand, I believe this is the typical way SAP recommends using Command Beans as a model in order to implement this type of simple component.
Let's see how the two same event handlers could be written with a more comprehensive object model at its disposal. One whose role is not limited to data access, but also capable of adequately presenting and manipulating the data that it encapsulates. (The actual code for these model beans will follow)
// I like to declare shortcut aliases for convenience...
private ProductCatalogBean catalog;
private ShoppingCartBean cart;
// and initialize them in the wdDoInit() method...
public wdDoInit(...)
if (firstTime)
catalog = wdContext.currentNodeProductCatalog().modelObject();
cart = wdContext.currentNodeShoppingCart ().modelObject();
Now the code for the event handlers:
public void onActionAddItemsToCart()
// add selected catalog items to shopping cart items collection
cart.addItems(catalog.getSelectedItems());
public void onActionRemoveItemsFromCart()
// remove selected shopping cart items from their collection
cart.removeItems(cart.getSelectedItems());
I feel these two lines of code are cleaner and easier to maintain than the two previous context-manipulation-ridden versions that accompany the command bean version.
Here's where the models are bound to their respective context nodes, in the Component Controller.
public supplyProductCatalogNode(IProductCatalogNode node, ...)
node.bind(new ProductCatalogBean(wdContext.getContext()));
public supplyShoppingCartNode(IShoppingCartNode node, ...)
node.bind(new ShoppingCartBean(wdContext.getContext()));
Notice that a context is provided in the constructors of both models (a generic context of type IWDContext). We saw earlier that our model needs to be able to respond to such requests as: catalog.getSelectedItem(). The user doesn't interact directly with the model, but with the Web Dynpro UI Elements. They in turn update the context... which is where our model will fetch the information it requires to do its job.
Also note that a model is provided for the shopping cart here, even though it has no need to access or execute anything on the back-end. Again, the model here is not being used as a command bean, but rather as a classic object model. We simply take advantage of the power of binding to make ourselves a clean and simple little helper that will update for us all the relevant context structures behind the scenes when we tell it to.
Here are the ShoppingCartBean and ProductCatalogBean classes (I've omitted a few getter/setter methods in order to reduce unnecessary clutter):
public class ShoppingCartBean
Collection items = new ArrayList();
IWDNode itemsNode;
public ShoppingCartBean(IWDContext context)
// initialize shortcut alias for ShoppingCartItems node
itemsNode = context.getRootNode()
.getChildNode("ShoppingCart", 0)
.getChildNode("ShoppingCartItems", 0);
public void addItems(Collection items)
this.items.addAll(items);
public void removeItems(Collection items)
this.items.removeAll(items);
public Collection getSelectedItems()
return ItemDTO.getSelectedItems(itemsNode);
public class ProductCatalogBean
Collection items;
IWDNode itemsNode;
public ProductCatalogBean(IWDContext context)
// fetch catalog content from back-end
items = new ProductCatalogBusinessDelegate().getItems();
// initialize shortcut alias for CatalogItems node
itemsNode = context.getRootNode()
.getChildNode("ProductCatalog", 0)
.getChildNode("CatalogItems", 0);
public Collection getSelectedItems()
return ItemDTO.getSelectedItems(itemsNode);
Notice that both classes delegate their getSelectedItems() implementation to a common version that's been placed in the ItemDTO class. It seems like a good place to put this type generic ItemDTO-related utility.
This DTO class could also have been used by the Command Bean version of the event handlers.. would reduce somewhat the number of loops. At any rate, the ItemDTO class shouldn't be viewed as an "overhead" to the model-based version, since it usually will have been created in the J2EE layer,for the marshalling of EJB data (see <a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html">Data Transfer Object Pattern</a>). We just take advantage of what's there, and extend it to our benefit for packaging some common ItemDTO-related code we require.
// DTO made available by the EJB layer
import com.mycompany.shoppingcart.dto.ItemDTO;
public class ItemDTO extends com.mycompany.shoppingcart.dto.ItemDTO
String code;
String description;
public ItemDTO()
public ItemDTO(String code, String description)
this.code = code;
this.description = description;
// returns ItemDTOs collection of currently selected node elements
public static Collection getSelectedItems(IWDNode node)
// create collection to be returned
Collection selectedItems = new ArrayList();
// loop through item node elements
for (i = 0; i < node.size(); i++)
// current item element selected ?
if (node.isMultiSelected(i))
// fetch selected item
IWDNodeElement item = node.getElementAt(i);
// transform item node element into ItemDTO
ItemDTO itemDTO = new ItemDTO(item.getAttributeAsText("Code"),
item.getAttributeAsText("Description"));
// add selected item to the selectedItems collection
selectedItems.add(itemDTO);
return selectedItems;
Notice that the getSelectedItem() method is the only place in our model where context node navigation and manipulation actually takes place. It's unavoidable here, given that we need to query these structures in order to correctly react to user actions. But where possible, the business logic - like adding items and removing items from the cart - has been implemented by standard java constructs instead of by manipulating context nodes and attributes.
To me, using a java bean model as an abstraction for the Context is much like using EJBs as abstractions of database tables and columns:
abstracts away
EJB model --------------> database tables & columns
abstracts away
WDP javabean model --------------> context nodes & attributes
Except that a javabean model (residing in the same JVM) is much more lightweight and easy to code an maintain than an EJB...
Before concluding, it might be worth pointing out that this alternative vision of the Web Dynpro Model in no way limits the possibility of implementing a Command Bean - if that happens to suit your business needs. You will of course always be able to implement an execute() method in your WDP Model if and when you feel the need to do so. Except that now, by breaking free of the mandatory Command Bean directive, you are allowed the freedom to ditch the execute() method if you don't need such a thing... and instead, replace it with a few well-chosen operations like getItems(), addItems(), removeItems(), getSelectedItems()... which, as we've just seen can add significant value to the javabean model made available to your WDP component.
Comments would be appreciated on this issue (if anyone has had the time/courage/patience to read this far...;). Am I alone here intrigued by the potential of this (up until now) scarcely mentionned design strategy ?
Romeo GuastaferriHi Romeo,
thanks for sharing this with the community. I am little bit surprised that the command pattern was understood as the only way on how to use the Javabean model in conjunction with EJBs. The command pattern blog of mine was just a very simplified example of how a functional call can be translated to a Java Bean model. Actually it was to show how the paradigm of a model works. I personally use a similar approach to yours. It seldomly makes sense to map an EJB method one to one to a model, but the javabean model must be driven by the Userinterface and represents a bridge between the business service layer and the ui. I personally even think that often it does not make sense to map RFC function like they are to the Web Dynpro Context. Most often you end up writing ZBAPIs that return structures like they are used in the UI. But if you use a java bean model as a layer in between your service layer, you are more flexible in evolving the application. Anyways design patterns for the java bean model need to be discussed more on SDN as they really add very valuable possibilities you would never have when working with value nodes alone. With the Javabean model we are back in the real OO world where things like inheritance work, things that are really not too well supported by the native WD features. I encapsulate every context of mine as javabeans. This has nothing to do with EJBs (which I am personally not a fan of) but only with the fact that I want to work with the power of the OO world.
rgds
David -
How to select a default value in a DropDownByIndex
Hi,
I have a dropdownbyindex in a table. I need to make default selection of an item in the dropdown.
I have prepopulated dropdown from bapi result, "1", "2", "3", "4". I have another bapi result which gives me a selected value "2". I need to default this to the dropdown when my page gets loaded.
1st bapi result - (model nodes)
_input
_output
_list
attribute (1,2,3,4) (list of elements)
I have a context node created for the table items.
nodeitems
str (2) -element to be defaulted.
I am writing this code:
int lead = 0;
for(int i = 0; i < X.size; i++){
IWDNodeElement elem = wdContext.nodeDataNode().getElementAt(i);
if(X.equalsIgnoreCase("2"))
lead = i;
break;
wdContext.nodeX.setLeadSelection(lead);
For size of X, I am taking
nodeInput.nodeOutput.nodeList.size()
But this gives me size of thelist 0 whereas it is populating the whole list.
Hope I have made it clear.
Please help.
ThanksCardinality Selection Singleton
_input - 0..n 0..1 true
_output - 0..1 0..1 true
_list - 0..n 0..1 true
nodeItem - 0..n 0..1 true
Thanks -
How to add a new element to a model node in the view controller?
View Context
myNode
attri1
attri2
myNode is a web service model node. How to add a new element to this node?
Regards,
Hui
Edited by: Hui Wang on Feb 15, 2008 12:05 PMSudhir Gorantla wrote:>
> Hi,
>
> myNode
> attri1
> attri2
>
> IMyNodeElement ele=wdContext.myNode().createMyNodeElement();
>
> ele.setAttri1("");
> ele.setAttri2("");
>
> wdContext.nodeMyNode().addElement(ele);
>
> Regards,
> Sudhir
Hi we need a model as an input parameter when creating a element for a model node. How to get the instance of the model?
Regards,
Hui -
How to bind a specific attribute of an element to an input field
HI,
in my web shop application I create an overview page of the items dynamically in the wdDoModify Method. Each item has it's own transparent container. I do not use tables or row repeaters, because they did not fullfill my requirements.
Now I have the problem to bind a specific attribute to an input field.
I bind the value with following code:
amountInput.bindValue(item.getAttributePointer("amount").getAttributeInfo())
item is the element of the item to display. amount is the attribute with type integer.
The problem is, that I have 4 Items on the screen. When I enter a value for amount, all amounts on the screen are the same. So I guess that the input field is not bound to the correct element.
Has anybody an idea what I have done wrong? Or which string for bindValue do I have to use for example for an attribute of the 5th element in a node?
Best regards,
PeterPeter, you can set the context node to mutiple select, but you have to select it on item variable, like:
item = wdContext.nodeXXX.getElementAt(1);
amountInput.bindValue(item.getAttributePointer("amount").getAttributeInfo())
item = wdContext.nodeXXX.getElementAt(2);
amountInput2.bindValue(item.getAttributePointer("amount").getAttributeInfo())
Regards,
Edson Thomaz -
Passing a multiple value in to inut table of BAPI in weddynpro java
Hi,
I am a facing a problem How to pass a more than one personnal perno in to inpuut parameter of Bapi which is a table(It_Pernr).
And Personnal nos are a output of anothe function module which we are displaying in Table and,,,, and from selecting a row of table we want to pass it in to another BAPI input(table type).
its very urgen ,,,, plz help me....Hi All,
Now I am able to pass a value in it_pernr table .
Actually for this we have to intantiate a object of model class which contains a personnel no in my case this is pernrtab, basically this is a internal table of backend system.
i implemented like below and for me its working fine
// Create and add the selected elements into a collection
list = new ArrayList();
for(int i=0; i<wdContext.nodeIt_Pernr().size(); i++) {
if(wdContext.nodeIt_Pernr().isMultiSelected(i)) {
list.add(wdContext.nodeIt_Pernr().getElementAt(i));
if (wdContext.nodeIt_Pernr().getLeadSelection() == 0) {
int j = wdContext.nodeIt_Pernr().getLeadSelection();
list.add(wdContext.nodeIt_Pernr().getElementAt(j));
//how to get back element
for(int i=0; i<list.size(); i++) {
//create object of model class pernrtab basically this is a internal table which contains personnel nos list
Pernrtab p = new Pernrtab();
IIt_PernrElement pernrElemnt = (IIt_PernrElement) list.get(i);
p.setPernr(pernrElemnt.getPernr());
inp2.addIt_Pernr(p);
Thanks,
Reagards
YAgyashikha
Edited by: yagyashikha on Jun 30, 2010 1:45 PM -
Hello Experts.
I am getting error when deleting from table.
please help me.I had given my error.
If possible also tell me how to trace this error.
java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.getElement(Node.java:2034)
at com.sap.tc.webdynpro.progmodel.context.Node.isMultiSelected(Node.java:841)
at com.sap.tc.webdynpro.progmodel.context.Node.isMultiSelected(Node.java:839)
at try1.comp1.TableView.onActionDelete_Entry(TableView.java:191)
at try1.comp1.wdp.InternalTableView.wdInvokeEventHandler(InternalTableView.java:191)
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:299)
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:160)
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)This Is the code of delete function.
//@@begin onActionDelete_Entry(ServerEvent)
int Count=wdContext.nodePerson().size();
int LeadSelcection=wdContext.nodePerson().getLeadSelection();
for(int i=0;i<Count;i++)
if( (i==LeadSelcection) || wdContext.nodePerson().isMultiSelected(i))
wdContext.nodePerson().removeElement(wdContext.nodePerson().getElementAt(i));
}//if
}//for
//@@end -
Drop down by index in table cell
Hello
I need for one column in table to have a drop down.
I have the the following context:
node: Zsi_Profile_TyperdvZish_Available_Timeslots_S_Rfc
subnode: X
value attribute in subnode X: a
Node X is singelton = false, selection: 0-1.
I am defined a drop down by index for one column and I want the data to come from node It_Rnpb2.
The code:
for (int i = 0; i< wdContext.nodeZsi_Profile_TyperdvZish_Available_Timeslots_S_Rfc().size();i++)
wdContext.nodeZsi_Profile_TyperdvZish_Available_Timeslots_S_Rfc().getElementAt(i);
for (int j = 0;j< wdThis.wdGetRendezVousCustomController().wdGetContext().nodeIt_Rnpb2().size();j++)
wdContext.nodeX().addElement(wdContext.createXElement());
wdContext.currentXElement().setA(wdThis.wdGetRendezVousCustomController().wdGetContext().nodeIt_Rnpb2().getIt_Rnpb2ElementAt(j).getOrgid());
The result is: for first table line a drop down with few empty lines and one of the line with the last value from It_Rnpb2, and for the other table lines drop downs just with an empty line.
How can I fix this?
Thank youLet me change those ugly node names into shorter ones and use an array containing the drop-down items for each row. I think you get the idea.
Table data source node: "Rows"
Non-singleton child node "Items", cardinality 0:N, with attribute "Text".
String TEXTS[][] with TEXT[r][j] = text of item j in row r
/* foreach row in table */
for (int r = 0; r < wdContext.nodeRows().size(); ++r)
IRowsElement row = wdContext.nodeRows().getRowsElementAt(r);
/* foreach drop-down list item */
for (int j = 0; j < TEXTS[r].length; ++j)
/* create item */
IItemsElement item = row.nodeItems().createItemsElement();
row.nodeItems().addElement(item);
/* set item text */
item.setText(TEXTS[r][j]);
I typed this code from memory so there might be minor errors.
Armin -
How to get the current node element by its value?
e.g,:
wdContext.current<b>Deal</b>Element().setAttributeValue("<i>deal_id</i>","<i>aaaaaaa</i>");
above code can get the result i wanna.
but now i wanna in terms of its node'name to set attribute vaue of itself. in other words,i have no idea about how to get the current node element by its name"<b>Deal</b>".Hi Wing,
The answer is there in your question itself.
wdContext.currentDealElement()
will give you the current node element by its name"Deal" or you could use
wdContext.nodeDeal().getCurrentElement()
or you could use
wdContext.nodeDeal().getElementAt(wdContext.nodeDeal().getLeadSelection())
Regards,
Sudeep
Maybe you are looking for
-
But when i try to sync my phone in itunes it won't let me because i don't have enough storage left on my iphone 5!!! How do i get around this catch 22? My son has a similar problem with his iphone4, except that he deleted everything off his phone (ph
-
HOW TO PRINT THE SCRIPT DIRECTLY
hi , i want to print the script directly by skiping the prini preview screen can any one help me.. regards, siva
-
I have an external HP dvd640v Lightscribe writer. I initially installed it onto a Windows 7 Startup OS, which I then upgraded to Windows 7 Professional. The device was running fine until yesterday when for some reason (maybe after a system auto updat
-
Help in customizing Folder Layout
All, any ideas on how we can get the folder layout to be vertically aligned top (i.e valign=top)? If you click on Folder Layout (in Content area->Folder Style), you see a space between the top of the folder and the Quick Picks. When we publish the fo
-
I am having problems with my hotmail and live emails and want to cancel them and use icloud email instead, is this possible and how do I do it by creating icloud emails, and using icloud emails