on 11-24-2009 9:21 AM
hi
I wanted to ask you that I'm using webdynpro recently and I have to do a program that does something like that
I enter the LinkToAction automatically according to the cycle for.ti make an example so it is easier
for (int = 0; i <10; i + +) (
/ / Put the LinkToAction
/ / Put the LinkToAction.Text
)
can do something like that???
Regards
Banana
Hi Friend,
You can Do by this way..
for (int = 0; i <10; i + +) (
/ / Put the LinkToAction
IWDLinkToAction link =wdContext.node<valueNode>)
.create<valueNode>Element().get<ValueAttributeofTypeLinkTOAction>();
link.setContextMenuId("linkToAction");
link.setOnAction(IWDAction);
link.setVisible(value)
// Keep setting the properties for desired relsult.
/ / Put the LinkToAction.Text
link.setText("SomeText");
)
Regards
Jeetendra.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for letting me Dreams4Desires responded
for (int i = 0; i <10; i + +) (
/ / Put the LinkToAction
IWDLinkToAction link = wdContext.nodeClassi().createProvElement().getVarLinkToAction();
link.setContextMenuId (linkToAction ");
link.setOnAction (IWDAction);
link.setVisible (value);
/ / Keep setting the desired properties for relsult.
/ / Put the LinkToAction.Text
link.setText (SomeText ");
)
but the error is
-Type mismatch:cannot convert from String to IWDLinkToAction -> IWDLinkToAction link = wdContext.nodeClassi().createProvElement().getVarLinkToAction();
-The method setContextMenuId (String) is undefined for the type IWDLinkToAction -> link.setContextMenuId (linkToAction ");
-IWDAction not be resolved -> link.setOnAction (IWDAction);
-value can not be resolved -> link.setVisible (value);
The Value Node is:
Prov
The Value Attribute is:
VarLinkToAction -> type String()
I did import these 2:
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDLinkToAction;
import com.sap.tc.webdynpro.progmodel.api.IWDAction;
Can you help?
Thanks
Hi friend
You have Created the variable VarLinkToAction of type String please Create it as IWDLinkToAction type you can do that by Going to java Native Type There you can Find IWDLinkToAction type.
And One More thing The IWDAction type you have to put some Action There which you want to use through the Link to action.
It May be IprivateView.On_action_<Some Action >.
Regards
Jeetendra
Thank you!
The first error is resolved
I now remain only these three errors:
-The method setContextMenuId (String) is undefined for the type IWDLinkToAction -> link.setContextMenuId (linkToAction ");
-IWDAction not be resolved -> link.setOnAction (IWDAction);
-value can not be resolved -> link.setVisible (value);
Can you help me?
Thanks
Banana
Hi friend,
-The method setContextMenuId (String) is undefined for the type IWDLinkToAction -> link.setContextMenuId (linkToAction ");
* link.setContextMenuId("LinkToAction"); // It will work You have left the (") thing before LinkToAction String.
-IWDAction not be resolved -> link.setOnAction (IWDAction); // See the Previous Post
-value can not be resolved -> link.setVisible (value); // link.setVisible(WDVisibility.VISIBLE); it will work.
Regards
Jeetendra.
Hi,
Use the following code in the action where you need to create Link to Action.
IWDView view = wdContext.currentContextElement().getVa_View();
IWDTransparentContainer root = (IWDTransparentContainer)view.getRootElement();
IWDLinkToAction la = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, "la_Test");
la.setOnAction(this.wdComponentAPI.getAction("<YourAction>"));
la.setEnabled(true);
la.setText("Do Test Action");
la.setVisible(WDVisibility.VISIBLE);
root.addChild(la);
Pre-requisite.
1. Create a context attribute Va_View and set it datatype from java native type
com.sap.tc.webdynpro.progmodel.api.IWDView
2. In wdDoModify() set the context attribute with --> view passed as argument in the wdDoModify method.
Regards,
Tushar Sinha
Hi
then I tried to post as you say
Tushar Sinha
IWDView view = wdContext.currentContextElement (). GetVista ();
IWDTransparentContainer root = (IWDTransparentContainer) view.getRootElement ();
IWDLinkToAction la = (IWDLinkToAction) view.createElement (IWDLinkToAction.class, "la_Test");
la.setOnAction (this.wdComponentAPI.getAction ("<MyAction> "));
la.setEnabled (true);
la.setText ( "Do Test Action");
la.setVisible (WDVisibility.VISIBLE);
root.addChild (la);
I deploy and gives me this error:
The initial exception that caused the request to fail, was:
java.lang.NullPointerException
at it.cvascuole.CVA_SCUOLE_DISEGNI_View.wdDoInit (CVA_SCUOLE_DISEGNI_View.java: 159)
at it.cvascuole.wdp.InternalCVA_SCUOLE_DISEGNI_View.wdDoInit (InternalCVA_SCUOLE_DISEGNI_View.java: 136)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit (DelegatingView.java: 61)
at com.sap.tc.webdynpro.progmodel.controller.Controller.initController (Controller.java: 215)
at com.sap.tc.webdynpro.progmodel.view.View.initController (View.java: 445)
... 32 more
the error is on
IWDTransparentContainer root = (IWDTransparentContainer) view.getRootElement ();
I created the node facie com.sap.tc.webdynpro.progmodel.api.IWDView
I also did as you say Dreams4Desires
IWDLinkToAction link = wdContext.nodeClassi (). CreateClassiElement (). GetVarLinkToAction ();
link.setContextMenuId ("LinkToAction");
link.setOnAction (IWDAction);
link.setVisible (WDVisibility.VISIBLE);
/ / Keep setting the desired properties for relsult.
/ / Put the LinkToAction.Text
link.setText (SomeText ");
the error is link.setContextMenuId ("LinkToAction"), says he does not know LinkToAction
and I also tried so link.setContextMenuId ("linkToAction"); same error
I do not know how to solve
can you help me?
Thanks
Banana
In the layout I did a Child Insert -> TransparentContainer and id = idAnno
and wdDoInit have this source:
IWDView view = wdContext.currentContextElement ().getVista ();
IWDTransparentContainer root = (IWDTransparentContainer) view.getElement ("idAnno");
IWDLinkToAction la = (IWDLinkToAction) view.createElement (IWDLinkToAction.class, "la_Test");
la.setOnAction (this.wdComponentAPI.getAction (<MyAction> "));
la.setEnabled (true);
la.setText ( "Do Test Action");
la.setVisible (WDVisibility.VISIBLE);
root.addChild (la);
right way?
gives the same error.
something wrong?
but it is right to put idAnno in IWDTransparentContainer root = (IWDTransparentContainer) view.getElement ("idAnno");?
thanks
Banana
Yes,
You need to first get the root element as what i have already suggested you using
IWDTransparentContainer root = (IWDTransparentContainer) view.getRootElement ();
It is different from the transparent container that you have inserted.
You see in the layout, the root transparent container cannot be deleted. Whatever you have inserted is within the root element.
So, follow this and add child to this root element only.
In wdDoMofify() make sure you just have this code:
if(firstTime){
wdcontext.currentContextElement().setVa_View(view);
}
This 'view' is a prameter passed in this wdDoModify() method. Try this.
Regards,
Tushar Sinha
Hi Friend,
On more suggession. In case you want to add the Link to URL to your newly added transparent container.
1. Get the view and then the root element (transparent container)
IWDView view = wdContext.currentContextElement().getVa_View();
IWDTransparentContainer root1 = (IWDTransparentContainer)view.getRootElement();
2. Get your transparent container and add to root element
IWDTransparentContainer root = (IWDTransparentContainer)view.getElement("idAnno");
root1.addChild(root,0);
3. Add the Link to URL in your transparent container
IWDLinkToAction la = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, "la_Test");
la.setOnAction(wdThis.wdGetPrintFileAction());
la.setEnabled(true);
la.setText("Do Test Action");
la.setVisible(WDVisibility.VISIBLE);
root.addChild(la);
Hope your problem is resolved now.
Regards,
Tushar Sinha
In your case the attribute name is Vista (where i refered the same attribute by name Va_View, type IWDView). In the wdDoModify() method in your view controller, if you can check is as below which has IWDView type parameter with name view. You actually need to set that to the context.
public static void wdDoModifyView(IPrivate<YourViewController> wdThis, IPrivate<YourViewController>.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime){
if(firstTime){
wdContext.currentContextElement ().setVista (view);
}
}
Regards,
Tushar Sinha
wdDoInit this source:
IWDView view = wdContext.currentContextElement().getVista();
IWDTransparentContainer root1 = (IWDTransparentContainer)view.getRootElement();
IWDTransparentContainer root = (IWDTransparentContainer)view.getElement("idAnno");
root1.addChild(root,0);
IWDLinkToAction la = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, "la_Test");
la.setOnAction(wdThis.wdGetPrintFileAction());
la.setEnabled(true);
la.setText("Do Test Action");
la.setVisible(WDVisibility.VISIBLE);
root.addChild(la);
in wdDoModifyView:
if(firstTime){
wdContext.currentContextElement ().setVista (view);
}
Error in:
IWDTransparentContainer root1 = (IWDTransparentContainer)view.getRootElement();
java.lang.NullPointerException
at com.sap.XXX_View.wdDoInit(XXX_View.java:164)
at it.cvascuole.wdp.InternalXXX_View.wdDoInit(InternalXXX_View.java:136)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)
at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:445)
... 32 more
I can not resolve ....
but somewhere there is an example already done?? perhaps a zip of the imported project
Help me!
Oh! got the problem. This is because you are trying to get the value from Vista context element even before the value is getting set. So null pointer is obvious.
wdDoInit() would always be called before the wdDoModify().
But why do you need to create element dynamically when the screen loads. You can better define that UI element in design time under layout and do all the binding manually there.
In case, you need to create element again after the screen has loaded once on some action, then you should use this dynamic creation, because by then the wdDoModify() method will be called at least once.
Regards,
Tushar Sinha
Finally it works!
Here's the source:
in wdDoModifyView
if(firstTime){
wdContext.currentContextElement().setVista (view);
IWDTransparentContainer rootElement = (IWDTransparentContainer) view.getRootElement();
// Set the layout manager to MatrixLayout
rootElement.createLayout(IWDMatrixLayout.class);
// Get the metadata of the node
IWDLinkToAction la = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, "la_Test");
la.setEnabled(true);
la.setText("Do Test Action");
la.setVisible(WDVisibility.VISIBLE);
rootElement.addChild(la);
}
Thanks for your help
Banana
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
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.