Dynamically Create Repeater Element in ActionScript
Hi,
I'm trying to dynamically create a repeater control with an
image and a label control. I can do it directly in the MXML file
but when I try and covert it into ActionScript it's not working.
Can anyone see what the problem is with my code?
public function GetPalettes():void{
removeChild(document.FrontPage);
Palettes.method = "GET";
params = {"method": "GetPalettes", "BodyPartNo":
document.PalettesMenu.selectedItem.@partNo};
Palettes.cancel();
Palettes.send(params);
var VerticalBox:VBox = new VBox();
VerticalBox.x = 10;
VerticalBox.y = 10;
VerticalBox.id = "VerticalBox";
var PaletteRepeater:Repeater = new Repeater();
PaletteRepeater.dataProvider =
"{Palettes.lastResult.Palette}";
PaletteRepeater.startingIndex = 0;
PaletteRepeater.id = "PaletteRepeater";
var PaletteImage:Image = new Image();
PaletteImage.setStyle("HorizontalAlign", "left");
PaletteImage.source = "
http://localhost/Flex/Personalised%20Palettes-debug/{PaletteRepeater.currentItem.@PictureS rc}Med.png";
PaletteImage.useHandCursor = true;
PaletteImage.buttonMode = true;
PaletteImage.mouseChildren = false;
PaletteImage.id = "PaletteImage";
var PaletteDescription:Label = new Label();
PaletteDescription.text =
"{PaletteRepeater.currentItem.@Description}";
PaletteDescription.id = "PaletteDescription";
document.MainPage.addChild(VerticalBox);
VerticalBox.addChild(PaletteRepeater);
PaletteRepeater.addChild(PaletteImage);
PaletteRepeater.addChild(PaletteDescription);
Thanks
"katychapman85" <[email protected]> wrote in
message
news:[email protected]...
> Hey Amy,
>
> I've put a thread up about this but thought I'd ask you
as well as you've
> been
> a great help to me so far.
>
> I have this function:
> public function GetOptions(Menu:int):void{
> document.MenuOptions.url =
> "
http://localhost/Flex/Personalised%20Palettes-debug/MenuOptions.php?Menu=";
> document.MenuOptions.url += Menu;
> document.MenuOptions.send();
> }
>
> What I'm trying to do is when a user clicks on a Radio
button this
> function is
> called and the number of the Menu required is sent to
the function.
>
> I've added this Event Listener to my Radio Button:
>
>
document.RadioButtons2.addEventListener(MouseEvent.CLICK,
> function():void{GetOptions(2);});
>
> However, it's not working. Everything I've read suggests
using an
> anonymous
> function in the Event Listener to pass the menu
parameter but for some
> reason
> it's not working.
What version of Flex are you using? The Help for Flex 3 has
this to say:
http://www.adobe.com/livedocs/flex/3/html/help.html?content=events_05.html
Defining event listeners inline
The simplest method of defining event handlers in Flex
applications is to
point to a handler function in the component's MXML tag. To
do this, you add
any of the component's events as a tag attribute followed by
an ActionScript
statement or function call.
You add an event handler inline using the following syntax:
<mx:tag_name event_name="handler_function"/>
For example, to listen for a Button control's click event,
you add a
statement in the <mx:Button> tag's click attribute. If
you add a function,
you define that function in an ActionScript block. The
following example
defines the submitForm() function as the handler for the
Button control's
click event:
<mx:Script><![CDATA[
function submitForm():void {
// Do something.
]]></mx:Script>
<mx:Button label="Submit" click="submitForm();"/>
Event handlers can include any valid ActionScript code,
including code that
calls global functions or sets a component property to the
return value. The
following example calls the trace() global function:
<mx:Button label="Get Ver" click="trace('The button was
clicked');"/>
There is one special parameter that you can pass in an inline
event handler
definition: the event parameter. If you add the event keyword
as a
parameter, Flex passes the Event object and inside the
handler function, you
can then access all the properties of the Event object.
The following example passes the Event object to the
submitForm() handler
function and specifies it as type MouseEvent:
<?xml version="1.0"?>
<!-- events/MouseEventHandler.mxml -->
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.controls.Alert;
private function myEventHandler(event:MouseEvent):void {
// Do something with the MouseEvent object.
Alert.show("An event of type '" + event.type + "'
occurred.");
]]></mx:Script>
<mx:Button id="b1" label="Click Me"
click="myEventHandler(event)"/>
</mx:Application>
It is best practice to include the event keyword when you
define all inline
event listeners and to specify the most stringent Event
object type in the
resulting listener function (for example, specify MouseEvent
instead of
Event).
You can use the Event object to access a reference to the
target object (the
object that dispatched the event), the type of event (for
example, click),
or other relevant properties, such as the row number and
value in a
list-based control. You can also use the Event object to
access methods and
properties of the target component, or the component that
dispatched the
event.
Although you will most often pass the entire Event object to
an event
listener, you can just pass individual properties, as the
following example
shows:
<?xml version="1.0"?>
<!-- events/PropertyHandler.mxml -->
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.controls.Alert;
private function myEventHandler(s:String):void {
Alert.show("Current Target: " + s);
]]></mx:Script>
<mx:Button id="b1" label="Click Me"
click="myEventHandler(event.currentTarget.id)"/>
</mx:Application>
Registering an event listener inline provides less
flexibility than using
the addEventListener() method to register event listeners.
The drawbacks are
that you cannot set the useCapture or priority properties on
the Event
object and that you cannot remove the listener once you add
it.
don't see anything in there about anonymous functions...?
Similar Messages
-
Prob in displaying the dynamically created ui elements on click of a button
hi all
i created 1 inputfield, 2 buttons & i wrote the following code in wddomodifyview() of view.
IWDInputField inf1=(IWDInputField)view.createElement(IWDInputField.class,"inf1");
inf1.bindValue("Student.name");
IWDButton but1=(IWDButton)view.createElement(IWDButton.class,"button1");
but1.setText("Button1");
IWDButton but2=(IWDButton)view.createElement(IWDButton.class,"button2");
but2.setText("Button2");
IWDTransparentContainer tc=(IWDTransparentContainer)view.getElement("TransparentContainer");
tc.addChild(inf1);
tc.addChild(but1);
tc.addChild(but2);
IWDButton button1= (IWDButton) view.getElement("button1");
IWDAction theAction=wdThis.wdCreateAction(IPrivateDynCompView.WDActionEventHandler.DISPLAY,"");
but1.setOnAction(theAction);
IWDParameterMapping bm1 = button1.mappingOfOnAction();
bm1.addParameter("id", "b1");
IWDButton button2= (IWDButton) view.getElement("button2");
IWDParameterMapping bm2 = button1.mappingOfOnAction();
bm1.addParameter("id", "b2");
and i wrote the following code in onactiondisplay()
if (id.equals("b1"))
wdContext.currentStudentElement().setName("First Button Clicked");
else
wdContext.currentStudentElement().setName("Second Button Clicked");
when i run the application, the following error is displaying.....
The initial exception that caused the request to fail, was:
com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "inf1" of type com.sap.tc.webdynpro.clientserver.uielib.standard.impl.InputField
at com.sap.tc.webdynpro.progmodel.view.View.addElement(View.java:481)
at com.sap.tc.webdynpro.progmodel.view.ViewElement.<init>(ViewElement.java:43)
at com.sap.tc.webdynpro.progmodel.view.UIElement.<init>(UIElement.java:188)
at com.sap.tc.webdynpro.clientserver.uielib.standard.impl.AbstractInputField.<init>(AbstractInputField.java:143)
at com.sap.tc.webdynpro.clientserver.uielib.standard.impl.InputField.<init>(InputField.java:71)
... 35 more
com.sap.tc.webdynpro.services.exceptions.WDCreationFailedException: Cannot create view element implementation com.sap.tc.webdynpro.clientserver.uielib.standard.impl.InputField
at com.sap.tc.webdynpro.progmodel.view.ViewElementFactory.createElement(ViewElementFactory.java:75)
at com.sap.tc.webdynpro.progmodel.view.View.createElement(View.java:89)
at com.sap.dynactions.DynCompView.wdDoModifyView(DynCompView.java:140)
at com.sap.dynactions.wdp.InternalDynCompView.wdDoModifyView(InternalDynCompView.java:240)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doModifyView(DelegatingView.java:78)
at com.sap.tc.webdynpro.progmodel.view.View.modifyView(View.java:190)
at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.doModifyView(ClientComponent.java:398)
at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.modifyView(ClientApplication.java:679)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:381)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:248)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
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:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
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:95)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at com.sap.tc.webdynpro.progmodel.view.ViewElementFactory.createElement(ViewElementFactory.java:65)
... 30 more
Caused by: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "inf1" of type com.sap.tc.webdynpro.clientserver.uielib.standard.impl.InputField
at com.sap.tc.webdynpro.progmodel.view.View.addElement(View.java:481)
at com.sap.tc.webdynpro.progmodel.view.ViewElement.<init>(ViewElement.java:43)
at com.sap.tc.webdynpro.progmodel.view.UIElement.<init>(UIElement.java:188)
at com.sap.tc.webdynpro.clientserver.uielib.standard.impl.AbstractInputField.<init>(AbstractInputField.java:143)
at com.sap.tc.webdynpro.clientserver.uielib.standard.impl.InputField.<init>(InputField.java:71)
... 35 more
pls tell me how to run this application without errors.....
thanks & regards,
vila.Hi Vila,
Issue here is you are trying to create Input field with already used id "inf1" in first line of code
IWDInputField inf1=(IWDInputField)view.createElement(IWDInputField.class,"inf1");
Please change it to
IWDInputField inf1=(IWDInputField)view.createElement(IWDInputField.class,"inf2");
and correspondingly line
tc.addChild(inf2);
Your code will work.
Please note that you should follow....following code style in wdDoModifyview
if(firstTime)
//dynamic view elements creation -
How to change Id of a dynamically created child element?
Hi,
I would like to change the id of the dynamically created elements in order to work easily with their later. Currently, edge automatically generate an random id like "eid_1376057792551" for each element.
There is my code :
sym.setVariable("labels", {
content2: "Visiteur",
content3: "Exposant",
content4: "Organisateur",
content5: "Contact",
content6: "Connexion"
// Clear initial state
sym.getSymbol("tab").deleteSymbol();
// Find all large symbols in the library
var prefix = "content"; // content1, content2 ... content99
var allTabs = [];
var symbolDefns = sym.getComposition().symbolDefns;
for (var key in symbolDefns) {
if (symbolDefns.hasOwnProperty(key) && key.search(new RegExp(prefix+"[0-9]{1,2}"))!=-1 ) {
var tab = sym.createChildSymbol( "tab", "navigation" );
tab.setVariable("contentId", key);
allTabs.push(tab);
tab.$("btnLabel").html( sym.getVariable("labels")[key] || "" );
$tabEl = tab.getSymbolElement();
$tabEl.data("sym", tab);
$tabEl.css({float: "left", margin: "0 -1px 15px 0"});
$tabEl.click(function(evt){
var tabSym = $(evt.currentTarget).data("sym");
$.each(allTabs, function(index,item) {
if (item != tabSym) { item.stop("normal"); item.setVariable("active", false); }
var $content = sym.$("content").empty();
sym.createChildSymbol(tabSym.getVariable("contentId"), "content");
Thank you .hi - trying to get this to work with no luck.
a simple example as i understand it:
var test = sym.createChildSymbol("rect", "Stage");
test.attr("id","test2");
would that work in changing the id of the newly created symbol to test2?
thanks! -
Create repeating elements in xml document
Good day,
I have a problem with a project I am busy with. I am creating an XML document from a predefined schema. I am able to this with no problem for one level using this method:
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
XmlSerializer serializer = new XmlSerializer(typeof(UKFATCASubmissionFIReport));
TextWriter writer = new StreamWriter(destinationPath);
UKFATCASubmissionFIReport fatcaSub = new UKFATCASubmissionFIReport();
fatcaSub.SchemaVersion = schemaVersion;
//Initialize classes and objects
#region classes and objects
AccountDataType accountData = new AccountDataType();
AccountHolderCodeType accountHolderType = new AccountHolderCodeType();
MessageDataType messageData = new MessageDataType();
MonetaryType moneyType = new MonetaryType();
SubmissionType submissionData = new SubmissionType();
FIReturnActionType fireturnActionData = new FIReturnActionType();
AccountActionType accountActionData = new AccountActionType();
TINCodeType tinCode = new TINCodeType();
HolderTaxInfoType holderInfo = new HolderTaxInfoType();
//PaymentDataType paymentData = paymentDetails();
#endregion
//Monetary type
moneyType.Value = moneyTypeValue;
moneyType.currCode = currCode_Type.GBP;
//Create message data
messageData.FATCAUserId = FatcaUserID;
messageData.XMLTimeStamp = timeStamp;
messageData.MessageCategory = MessageType.NewSubmission;
fatcaSub.MessageData = messageData;
//Create submission data object
submissionData.ReportingPeriod = reportingPeriod;
submissionData.Item = messageRef;
fatcaSub.Item = submissionData;
//FI Return Action
fireturnActionData.Action = ActionType.New;
fireturnActionData.FIReturnRef = returnRef;
//FIReturnActionType[] fireturnItems = new FIReturnActionType[] { fireturnActionData };
//TIN Code Type
tinCode.TINCountryCode = countryCode;
tinCode.Value = tinCodeValue;
tinCode.TINCountryCodeSpecified = itemSpecified;
//TIN Information
holderInfo.ReportableJurisdiction = countryCode;
holderInfo.TIN = holderTIN;
holderInfo.TINCode = tinCode;
//ContactPersonInformation contactInfo = ContactInformation(holderInfo);
//Contact address
ContactAddressType contactAddress = new ContactAddressType();
contactAddress.StreetName = streetName;
contactAddress.City = contactCity;
contactAddress.CountryCode = holderInfo.ReportableJurisdiction;
//Person Details
ContactPersonInformation contactInfo = new ContactPersonInformation();
contactInfo.FirstName = firstName;
contactInfo.LastName = lastName;
contactInfo.Address = contactAddress;
contactInfo.HolderTaxInfo = holderInfo;
contactInfo.BirthDateSpecified = itemSpecified;
contactInfo.BirthDate = dateOfBirth;
PaymentMonetaryType paymentMonetary = new PaymentMonetaryType();
paymentMonetary.currCode = currCode_Type.GBP;
paymentMonetary.Value = paymentValue;
//Payment data object
PaymentDataType paymentData = new PaymentDataType();
paymentData.PaymentCode = PaymentCodeType.Item20;
paymentData.PaymentAmount = paymentMonetary;
//return paymentData;
//Account action
accountActionData.AccountRef = accountRef;
accountActionData.Action = ActionType.New;
//Account information array
//AccountData(paymentData, contactInfo, accountActionData, accountData, accountHolderType);
object[] accountItems = new object[] { accountActionData, accountNumber, paymentData, accountHolderType, contactInfo };
accountData.Items = accountItems;
ItemsChoiceType[] accountFieldNames = new ItemsChoiceType[] { ItemsChoiceType.AccountAction, ItemsChoiceType.AccountNumber, ItemsChoiceType.PaymentData, ItemsChoiceType.AccountHolderType, ItemsChoiceType.Person };
accountData.ItemsElementName = accountFieldNames;
//Financial Information Return main array
//FIReturn(submissionData, fireturnActionData, accountData);
FIReturnType fireturn = new FIReturnType();
object[] fiItems = new object[] { fireturnActionData, fiRegisterID, dueDilligenceInd, thresholdInd, accountData };
fireturn.Items = fiItems;
ItemsChoiceType1[] fiFieldnames = new ItemsChoiceType1[] { ItemsChoiceType1.FIReturnAction, ItemsChoiceType1.FIRegisterId, ItemsChoiceType1.DueDiligenceInd, ItemsChoiceType1.ThresholdInd, ItemsChoiceType1.AccountData };
fireturn.ItemsElementName = fiFieldnames;
FIReturnType[] fiData = new FIReturnType[] { fireturn };
//Map FI return data to submissionData
submissionData.FIReturn = fiData;
//Serialize the submission close the TextWriter
serializer.Serialize(writer, fatcaSub);
writer.Close();
Process.Visible = false;
MessageBox.Show("Processing Complete!", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
Close();
The problem is that I would like fireturn to appear in the document more than once from a dataset. If I changed my code to this:
FIReturnType[] fiData = new FIReturnType[] { fireturn, fireturn, fireturn };
//Map FI return data to submissionData
submissionData.FIReturn = fiData;
I am able to get the three elements as required. How can I change my code to allow for a foreach statement for example?I managed to change FIReturnType into a list as below. I have a sample datatable also. My code now creates the nodes as expected but the all contain the last item only. What do I need to change so that I get the correct values written?
DataTable dtTable = new DataTable();
dtTable.Columns.Add("FirstName", typeof(string));
dtTable.Columns.Add("Surname", typeof(string));
// Here we add five DataRows.
dtTable.Rows.Add("Test", "Test");
dtTable.Rows.Add("Two", "Three");
dtTable.Rows.Add("Four", "Five");
dtTable.Rows.Add("Six", "Seven");
dtTable.Rows.Add("Eight", "Nine");
List<FIReturnType> fiRetList = new List<FIReturnType>();
foreach (DataRow row in dtTable.Rows)
object fName = row["FirstName"];
object sName = row["Surname"];
contactInfo.FirstName = fName.ToString();
contactInfo.LastName = sName.ToString();
FIReturnType fireturn = new FIReturnType();
object[] fiItems = new object[] { fireturnActionData, fiRegisterID, dueDilligenceInd, thresholdInd, accountData };
fireturn.Items = fiItems;
ItemsChoiceType1[] fiFieldnames = new ItemsChoiceType1[] { ItemsChoiceType1.FIReturnAction, ItemsChoiceType1.FIRegisterId, ItemsChoiceType1.DueDiligenceInd, ItemsChoiceType1.ThresholdInd, ItemsChoiceType1.AccountData };
fireturn.ItemsElementName = fiFieldnames;
fiRetList.Add(new FIReturnType { Items = fiItems, ItemsElementName = fiFieldnames });
FIReturnType[] fiData = fiRetList.ToArray();
submissionData.FIReturn = fiData; -
How to Access the Dynamically created form element
Hi friends,
I have generated a dynamic form in flex using xml and i want to save the all the elements of the form with there label and entered data in the formItem.
so i m getting how to save the data.
anybody have idea about this?????
Thanking you
GajananThanks for your reply.
as u said i have done this
for each(var formItem:FormItem in form.getChildren()){
formItem.label //The FormItem's label's text
formItem.getChildAt(0) //The first child - TextInput, ComboBox or whatever you got
Alert.show(formItem.getChildAt(0).toString());
return;
my first child formitem is TextInput and i entered some value in tat textInput but i m printing this i m getting the "dynamicform.ApplicationSkin3._ApplicationSkin_Group1.contentGroup.grp.Form0.FormItem15.txt studentfname" i m getting this output
i want to access the entered value of in the textInput.
Thanks,
gajanan -
Dynamic create elements and drag drop
Hi,
Where can I find an example of dynamic creating swing elements
and drag-drop them?
Thanks,
Luiz Fernandototalnewby wrote:
The following procedure doesn't compile if sequence SEQ_ADR does not exist before compilation. I had to create the sequence manually before being able to compile this procedure. How can I avoid this manual generation?
PROCEDURE A_270(proc_id number) IS
seq_cnt number;
curr_max number;
BEGIN
select count(*) into seq_cnt from user_sequences where sequence_name='SEQ_ADR';
if seq_cnt > 0 then
execute immediate 'drop sequence SEQ_ADR';
end if;
select max(id)+1 into curr_max from adress;
execute immediate 'create sequence SEQ_ADR start with '||curr_max||'';
insert into adress(ID,
IMPORTED_DT
select
SEQ_ADR.nextval ID,
sysdate IMPORTED_DT
from new_adress;
END;Edited by: totalnewby on Aug 23, 2012 6:41 AMEssentially the same question asked by 'gogol' two days ago at creating and using sequence inside a proc
It was a bad idea then. It is a bad idea now. -
How to bind the attribute in the context to a dynamic created element?
Hi, experts,
There are some attributes in the node context(ee_node) that contained the attribute named "ANSSA" in the view(test_view) in the WDA for abap. In the method modifyview of the view(there is a transfered parameter that represent the name of "ANSSA")
I want to create a dynamic element(inputfield) in the test_view. The element need bind the context attribute (ANSSA).Through the transfered parameter(para), I only know the name of the attribute binded.
How can I bind the attribute of the context in the following code?
METHOD modifyview .
*importing para type string.
*importing m_view type ref to if_wd_view.
data wd_inputfield type ref to cl_wd_input_field.
create one element automatically in the view.
wd_inputfield = CL_WD_INPUT_FIELD=>NEW_INPUT_FIELD(
view = m_view
id = para
BIND_VALUE = ???
ENDMETHOD.
I don't know how to replace the "???" in the method modifyview? Do you give me some hint for it?
You can reply back to me via e-mail if you think we should discuss this internally at [email protected] or [email protected]
Thanks.
Best regards,
taoHi, Suresh,
Thanks a lot for your help.
The last mail have some errors. Now, I modify my code error. The following is my new code in the wddomodifyview method in the ADDR_AUTO_DISP_VIEW view.
Now, I modify my code. The following is my new code in the wddomodifyview method in the ADDR_AUTO_DISP_VIEW view.
METHOD wddomodifyview .
importing view type ref to if_wd_view.
DATA transparent_container TYPE REF TO cl_wd_transparent_container.
DATA inputfield type ref to cl_wd_input_field.
transparent_container ?= view->get_element( `TRANSPARENT_CONTAINER` ).
transparent_container->set_visible(
EXPORTING
value = if_wdl_core=>visibility_visible ).
wd_this->SET_DYNAMIC_INPUT(
EXPORTING
inputfield_ID = 'ANSSA'
IMPORTING
INPUTFIELD = inputfield
**************The web page will occur error when running the WDA as soon as I write the code.***********
transparent_container->add_child( THE_CHILD = inputfield ).
ENDMETHOD.
The following is the code of the SET_DYNAMIC_INPUT method.
method SET_DYNAMIC_INPUT .
*importing
*INPUTFIELD_ID type STRING
*exporting
*INPUTFIELD type ref to CL_WD_INPUT_FIELD
Data binded_context type string.
concatenate 'ADDR_AUTO_DISP_VIEW.EE_ADDRESS.' INPUTFIELD_ID into binded_context .
inputfield = CL_WD_INPUT_FIELD=>NEW_INPUT_FIELD(
id = inputfield_id
read_only = abap_true
BIND_VALUE = binded_context
endmethod.
When I run the WDA, The web page occuring the error information:
Note
The following error text was processed in the system DEV : Access via 'NULL' object reference not possible.
The error occurred on the application server devserver_DEV_00 and in the work process 0 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L7STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L7STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L7STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L7STANDARD==============CP
Method: IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program /1WDA/L8STANDARD==============CP
But when I delete the code of the wddomodifyview, and create a inputfield in the layout of the view, and bind the "ANSSA" to the "value" property in the layout, the WDA is running correctly.
Do you give me some hints?
Thanks a million.
Best regards,
tao -
Create multiple elements dynamically at one time
Hi,
I need to create some links dynamically.
Below is my code... but I need to know instead of multiple steps.. is there a way to create dynamic elements together using one method itself.... or once i create the elements can i embed all these links together in the view?
lr_lta = cl_wd_link_to_action=>new_link_to_action(
id = 'LNK_CREATE'
on_action = 'ON_NAVIGATE'
text = 'Create'
view = lr_view ).
cl_wd_matrix_data=>new_matrix_data( element = lr_lta ).
lr_container->add_child( the_child = lr_lta ).
lr_lta = cl_wd_link_to_action=>new_link_to_action(
id = 'LNK_HISTORY'
on_action = 'ON_NAVIGATE'
text = 'Hitory'
view = lr_view ).
cl_wd_matrix_data=>new_matrix_data( element = lr_lta ).
lr_container->add_child( the_child = lr_lta ).
Any help will be grateful.
Regards and Thanks
TenzinHi,
This is a sample code for doing it using loop.
I just refined the code to make it most amenable to your requirement.
The code gives two different links at the same time with two different actions.
method WDDOMODIFYVIEW .
IF first_time eq abap_true.
data lr_ref type ref to cl_wd_link_to_action.
data lr_cont_ref type ref to cl_wd_uielement_container.
data lr_layo_ref type ref to cl_wd_flow_data.
data lv_times type i value 2.
data lv_count type i value 1.
lr_cont_ref ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
do lv_times times. "decide how many times you want the link
case lv_count. "decide what link to action with what action should be defined
when 1.
CALL METHOD cl_wd_link_to_action=>new_link_to_action
EXPORTING
enabled = ABAP_TRUE
image_first = ABAP_TRUE
on_action = 'First_Action'
text = 'First Link' "to display 'Gangtok' when clicked
receiving
control = lr_ref
CALL METHOD cl_wd_flow_data=>new_flow_data
EXPORTING
element = lr_ref
receiving
control = lr_layo_ref
CALL METHOD lr_cont_ref->add_child
EXPORTING
index = 1 "this is to set link to action in first place
the_child = lr_ref
When 2.
CALL METHOD cl_wd_link_to_action=>new_link_to_action
EXPORTING
enabled = ABAP_TRUE
image_first = ABAP_TRUE
on_action = 'Second_Action' "to display 'Kolkata' when clicked
text = 'Second Link'
receiving
control = lr_ref
CALL METHOD cl_wd_flow_data=>new_flow_data
EXPORTING
element = lr_ref
receiving
control = lr_layo_ref
CALL METHOD lr_cont_ref->add_child
EXPORTING
index = 2 "this is to set the link to action in 2nd place
the_child = lr_ref
endcase.
lv_count = lv_count + 1.
enddo.
endif.
endmethod.
Regards,
Prosenjit.
Edited by: prosenjit chaudhuri on Feb 16, 2009 12:48 PM -
Create UI elements dynamically in AppleScript Studio?
I'd like to create an applescript studio app that can create UI elements (radio buttons, checkboxes, etc) dynamically based on certain other criteria. I've been writing applescripts for a while but am somewhat new to applescript studio, so I don't know where to look for this, other than here. Any help would be greatly appreciated.
that's what I thought. Unfortunately I'd like to have the ability to have no prior knowledge of what UI elements are needed, and call them into being at any time. So I'm gonna infer that that just isn't possible.
Related question: can I set up a UI element, let's say a checkbox, and dynamically tell the UI element how many checkboxes I need and what their names/values should be? Or once again do I need to have prior knowlege of how many checkboxes I need? -
Dynamically create TRAY view element.
I am trying to create a little menu using a stack of trays with related buttons under each tray.
I cannot find an example of a dynamically created tray. Every instance of NEW_TRAY in my NW07 system is generated and the system won't show it to me so I can't see how to use it.
The problem that I get is an assertion failure after a test 'IF VIEW_ELEMENT IS NOT BOUND.' Obviously I have a null reference somewhere, but with no documentation (that I can find) I need an example.
I would settle for any container-like object at all. Doesn't have to be a tray. I cannot even get it to work with a transparent container. You can't even see it - so how can it be complicated?
Please form an orderly line, and no fighting to be first with the solution!
Russ.Hello Russ,
I have used a container in the message area. Have a look at CL_WDR_MESSAGE_AREA~CREATE_MSG_LIST for example.
Regards,
Rainer -
How to delete Dynamically created input field UI Element
Hi all,
I want to delete dynamically created input field and label.
Is there any method please tell.
Thanks in advance
HemalathaHi,
In the WDEVENT parameter of the action handler you can find the event id.
***Variables
DATA:
lv_selected type string. "Selected tab value
***Structure and internal table for the Events and messages
DATA:
lt_events type WDR_EVENT_PARAMETER_LIST,
ls_events type WDR_EVENT_PARAMETER.
***Field symbols
field-symbols: <fs_value> type any. "Attribute value in events table
***Move the event table to lt_events
lt_events = wdevent->parameters.
read table lt_events into ls_events with key name = 'SAVE'. "Button Id
if sy-subrc eq 0.
assign ls_events-value->* to <fs_value>.
if sy-subrc eq 0.
lv_selected = <fs_value>.
endif. "IF sy-subrc eq 0.
endif. "IF sy-subrc eq 0.
Regards,
Lekha. -
Howto dynamicly bind XML element to a TextInput using BindingUtils?
The question is: Howto dynamicly bind XML element to a
TextInput component using BindingUtils?
Now I use following codes:
<!--
[Bindable] private var xml: XML =
<item><label>list1</label></item>;
// initialize code for application's initialize event
private function init(): void {
BindingUtils.bindProperty(txtDemo, "text", xml, "label");
//click event
private function test(): void {
xml.label = "something";
// txtDemo.executeBindings(); //---- no use anymore
-->
<mx:TextInput id="txtDemo"/>
<mx:Button label="Test" click="test()"/>
My really idea is when bindable xml property is changed, then
the textinput will be updated as hoped. However, no update happens
to me when I click the Test button.
But, if I make codes like that:
<mx: TextInput id="txtDemo" text="{xml.label}"/>
the text will updated when xml changs.
So, what happened, I indeed need the dynamicly bind to the
textinput compont.
Help me. thanks.You could use an ObjectProxy since all subproperties will
then be bindable:
private var _xml:XML =
<item><label>list1</label></item>;
private var _opXML:ObjectProxy = new ObjectProxy(_xml);
then in your init() function you declare _opXML as the host
object with the bindable property "label"...
// initialize code for application's initialize event
public function init(): void {
BindingUtils.bindProperty(txtDemo, "text", _opXML, "label");
//click event
private function test(): void {
_opXML.label = "something";
You'll notice that if you check your original _xml.label
property with ChangeWatcher.canWatch(), it returns false. But if
you create a dedicated object with a property that can be declared
as bindable, canWatch() returns true. You'd probably be best off to
write a lightweight class that can act as your model if you want to
work with dynamic XML binding using Actionscript. This will allow
you to use a bindable getter and setter that will give you the
dynamic functionality you're looking for.
Hope that helps. -
How to get the co-ordinates of a dynamically created input field
Hello Frn's
i have created a dynamic text view . but this text view is not appearing at proper position . I want palce it infront of a dynamically created input field . how can i do this ?
as i am thinking ...i should first of all get info about the co-ordinates of dynamaclly creatd input field . and with respect to these co-ordinates ...set the position of text View .
Please suggest your thoughts .
Thanks and Regards
Priyank DixitHi,
There is no provision in WD for getting screen coordinates and then placing the UI element.
You to add the UI element to layout editor and based on the layout type it will add the UI element to respective position.
I would advice not to create dynamic UI elements( instead you can create them statically and then play with visibility status through context binding ). This will be more effective way and less error prone. This is also recommended practice.
still,For dynamic creation you can refer to following wiki:
http://wiki.sdn.sap.com/wiki/display/WDABAP/CreatingUIElementsDynamicallyinAbapWebdynpro+Application
regards
Manas Dua -
Dynamic tree UI element in the view
Dear All,
Can anyone provide me with the code snippet for Dynamic Tree UI element in the view. I need to show the tree which should be generated dynamically.
Thanks alot in advance!
Points will be rewarded, Please its urgent!
Cheers,
Darshna.Hi ,
sorry for the late reply... here is the code for onActionLoadchildren .. i am sure you wont understand this.. but lets try...
DATA:
element_parent TYPE REF TO if_wd_context_element,
lv_object_key1 type string,
lv_object_type type string.
DATA:
node_root_entry TYPE REF TO if_wd_context_node,
elem_root_entry TYPE REF TO if_wd_context_element,
stru_root_entry TYPE if_structure_view_new=>element_root_entry ,
item_valid_from LIKE stru_root_entry-valid_from,
item_plant LIKE stru_root_entry-plant,
item_equi_key LIKE stru_root_entry-equi_key,
item_object_key LIKE stru_root_entry-object_key,
item_object_type TYPE string,
item_path TYPE string,
item_parent_path TYPE string,
context_node TYPE REF TO if_wd_context_node,
root_entry TYPE if_structure_view_new=>element_selected_entry.
l_ref_componentcontroller TYPE REF TO ig_componentcontroller.
DATA:
node_root_info TYPE REF TO if_wd_context_node,
elem_root_info TYPE REF TO if_wd_context_element,
stru_root_info TYPE if_structure_view_new=>element_root_info .
DATA:
element TYPE REF TO if_wd_context_element,
node_selected_entry TYPE REF TO if_wd_context_node,
elem_selected_entry TYPE REF TO if_wd_context_element.
DATA:
ls_hier_return TYPE rplm_ts_struc_elements,
lt_hier_return TYPE TABLE OF rplm_ts_struc_elements,
ls_hier_return_temp TYPE rplm_ts_struc_elements,
lt_hier_return_temp TYPE TABLE OF rplm_ts_struc_elements,
ls_hier_level TYPE rplm_ts_hier_level,
lt_hier_level TYPE TABLE OF rplm_ts_hier_level,
ls_hier_return_sort TYPE rplm_mt_ts_hier,
lt_hier_return_sort TYPE TABLE OF rplm_mt_ts_hier.
DATA:
temp_hier_level TYPE if_structure_view_new=>element_hier_level,
lt_hier_temp TYPE TABLE OF if_structure_view_new=>element_hier_level,
lt_temp TYPE TABLE OF if_structure_view_new=>element_hier_level.
DATA:
lc_path TYPE string,
lv_object_key TYPE string.
DATA:
lv_hier_lines TYPE i.
DATA:
node_entries TYPE REF TO if_wd_context_node,
node_sub_entries TYPE REF TO if_wd_context_node,
elem_sub_entries TYPE REF TO if_wd_context_element,
stru_sub_entries TYPE if_structure_view_new=>element_sub_entries .
TYPES: BEGIN OF ls_hier_type, "structure for Hierarchy table
object(31) TYPE c, "Objectkey
predecessor(31) TYPE c, "Objectkey Predecessor
data(2000) TYPE c, "Data container
level TYPE i, "level of object in tree
successors(1) TYPE c, "Object has successors: YES/NO/U
display(1) TYPE c, "Object is displayed: YES/NO
selected(1) TYPE c, "Object is selected/marked: YES/NO
index_predec LIKE sy-tabix, "Index predecessor
strno TYPE ilom_strno,"External number for func. loc.
"in BOMs used for top object
END OF ls_hier_type.
DATA:
ls_hier TYPE ls_hier_type,
lt_hier TYPE TABLE OF ls_hier_type WITH DEFAULT KEY,
lt_mat_hier TYPE TABLE OF ls_hier_type WITH DEFAULT KEY.
" For retrieving Material Data Heirarchy
DATA:
lh_stpo_tab TYPE TABLE OF rihstpx ,
lwa_stpo_tab LIKE LINE OF lh_stpo_tab,
check_menge TYPE string ,
check_meins TYPE string ,
lwa_mat_hier LIKE LINE OF lt_mat_hier ,
lt_dup_mat_hier LIKE lt_mat_hier,
lv_len TYPE i,
lv_len_temp TYPE i .
DATA:
lv_equnr TYPE equi-equnr,
lv_tplnr TYPE iflo-tplnr,
lv_matnr TYPE mast-matnr.
DATA:
lv_cnt TYPE i,
lv_index TYPE i.
DATA:
lv_path TYPE string,
lv_parent_path TYPE string,
pos TYPE string,
separator TYPE c VALUE '.',
max_level TYPE i,
temp_level TYPE i,
counter TYPE i VALUE 1.
TYPES: BEGIN OF ls_pred_type, "structure for Hierarchy table
parent(31) TYPE c, "Objectkey Predecessor
path(2000) TYPE c, "Data container
index_predec LIKE sy-tabix, "Index predecessor
END OF ls_pred_type.
DATA:
ls_pred TYPE ls_pred_type,
lt_pred TYPE TABLE OF ls_pred_type WITH DEFAULT KEY.
DATA:
lv_int_obj_key TYPE string,
obj_len TYPE i,
lv_funcloc_ext TYPE ilom_strno,
lv_funcloc TYPE itob-tplnr.
DATA:
lv_level TYPE i,
lv_temp TYPE i,
lt_path_entries TYPE string_table.
DATA:
node_general TYPE REF TO if_wd_context_node,
elem_general TYPE REF TO if_wd_context_element,
stru_general TYPE if_structure_view_new=>element_general ,
item_collapse_visibility LIKE stru_general-collapse_visibility.
DATA:
elem_context TYPE REF TO if_wd_context_element,
stru_context TYPE if_structure_view_new=>element_context ,
item_expand_all LIKE stru_context-expand_all.
lv_path = path.
Get Element whose children shall be loaded
element_parent = wd_context->path_get_element( lv_path ).
element_parent->get_attribute(
EXPORTING
name = `OBJECT_KEY`
IMPORTING
value = LV_object_key ).
element_parent->get_attribute(
EXPORTING
name = `OBJECT_TYPE`
IMPORTING
value = lv_object_type ).
node_root_entry = wd_context->get_child_node( name = wd_this->wdctx_root_entry ).
get element via lead selection
elem_root_entry = node_root_entry->get_element( ).
get single attribute
elem_root_entry->get_attribute(
EXPORTING
name = `VALID_FROM`
IMPORTING
value = item_valid_from ).
elem_root_entry->get_attribute(
EXPORTING
name = `PLANT`
IMPORTING
value = item_plant ).
item_object_type = lv_object_type.
if lv_object_type eq 'EQUI'.
item_object_key = ''.
item_equi_key = lv_object_key.
elseif lv_object_type eq 'FUNCLOC'.
item_object_key = lv_object_key.
item_equi_key = ''.
ELSE.
lv_matnr = lv_object_key.
For BOM, material and Assembly
endif.
IF item_object_type EQ 'EQUI'.
lv_equnr = lv_object_key.
ELSEif item_object_type eq 'FUNCLOC'.
lv_tplnr = lv_object_key.
ELSE.
LV_MATNR = lv_object_key.
exit.
ENDIF.
CALL FUNCTION 'PM_HIERARCHY_CALL'
EXPORTING
datum = item_valid_from
equnr = lv_equnr
tplnr = lv_tplnr
matnr = lv_matnr
levdo = '99'
levup = '00'
sanin = 'X'
select_equi = 'X'
select_iflo = 'X'
select_stpo = 'X'
selmod = 'D'
stkkz = ''
werks = item_plant
with_equi = 'X'
with_equi_hier = 'X'
with_iflo_hier = 'X'
with_btyp = 'X'
with_mara = 'X'
with_ibase_hier = ''
capid = ''
emeng = 0
IMPORTING
et_hier = lt_hier
EXCEPTIONS
no_hierarchy = 1
no_object_defined = 2
no_selection = 3
no_valid_equnr = 4
no_valid_matnr = 5
no_valid_selmod = 6
no_valid_tplnr = 7
OTHERS = 8.
LOOP AT lt_hier INTO ls_hier.
ls_hier_return-object_key = ls_hier-object.
ls_hier_level-object_key = ls_hier-object.
ls_hier_level-predecessor = ls_hier-predecessor.
lv_len = strlen( ls_hier-object ).
IF lv_len GT 1.
lv_len_temp = lv_len - 1.
ELSEIF
lv_len_temp = lv_len.
ENDIF.
ls_hier_level-level = ls_hier-level.
IF ls_hier-object(1) = 'T'.
ls_hier_return-icon = 'ICON_TECHNICAL_PLACE'.
ls_hier_return-object_type = 'FUNCLOC'.
IF ls_hier-successors = 'Y'.
ls_hier_return-is_leaf = abap_false.
ls_hier_return-is_expanded = abap_false.
ls_hier_return-children_loaded = abap_true.
ELSE.
ls_hier_return-is_leaf = abap_true.
ls_hier_return-is_expanded = abap_true.
ls_hier_return-children_loaded = abap_true.
ENDIF.
ELSEIF ls_hier-object(1) = 'E'.
ls_hier_return-icon = 'ICON_EQUIPMENT'.
ls_hier_return-object_type = 'EQUI'.
IF ls_hier-successors = 'Y'.
ls_hier_return-is_leaf = abap_false.
ls_hier_return-is_expanded = abap_false.
ls_hier_return-children_loaded = abap_true.
ELSE.
ls_hier_return-is_leaf = abap_true.
ls_hier_return-is_expanded = abap_true.
ls_hier_return-children_loaded = abap_true.
ENDIF.
ELSEIF ls_hier-object+lv_len_temp(1) = 'M'.
ls_hier_return-icon = 'ICON_MATERIAL'.
ls_hier_return-object_type = 'MATERIAL'.
IF ls_hier-successors = 'Y'.
ls_hier_return-is_leaf = abap_false.
ls_hier_return-is_expanded = abap_false.
ls_hier_return-children_loaded = abap_false.
ELSE.
ls_hier_return-is_leaf = abap_true.
ls_hier_return-is_expanded = abap_true.
ls_hier_return-children_loaded = abap_true.
ENDIF.
ELSEIF ls_hier-object+lv_len_temp(1) = 'X'.
ls_hier_return-icon = 'ICON_SUPPLY_AREA'.
ls_hier_return-object_type = 'MATBOM'.
IF ls_hier-successors = 'Y'.
ls_hier_return-is_leaf = abap_false.
ls_hier_return-is_expanded = abap_false.
ls_hier_return-children_loaded = abap_false.
ELSE.
ls_hier_return-is_leaf = abap_true.
ls_hier_return-is_expanded = abap_true.
ls_hier_return-children_loaded = abap_true.
ENDIF.
ELSEIF ls_hier-object+lv_len_temp(1) = 'A'.
ls_hier_return-icon = 'ICON_MATERIAL_REVISION'.
ls_hier_return-object_type = 'MATERIAL'.
IF ls_hier-successors = 'Y'.
ls_hier_return-is_leaf = abap_false.
ls_hier_return-is_expanded = abap_false.
ls_hier_return-children_loaded = abap_false.
ELSE.
ls_hier_return-is_leaf = abap_true.
ls_hier_return-is_expanded = abap_true.
ls_hier_return-children_loaded = abap_true.
ENDIF.
ENDIF.
*IF ls_hier-predecessor EQ item_object_key OR ls_hier-object EQ item_object_key.
APPEND ls_hier_return TO lt_hier_return.
APPEND ls_hier_level TO lt_hier_level.
*ENDIF.
CLEAR lv_len.
CLEAR lv_len_temp.
ENDLOOP.
lt_hier_return_temp = lt_hier_return.
DESCRIBE TABLE lt_hier LINES lv_hier_lines.
IF lv_hier_lines EQ 0.
elem_selected_entry = wd_context->path_get_element( '1.ENTRIES.1' ).
Get children node
elem_selected_entry->set_attribute(
value = abap_true
name = 'IS_LEAF' ).
ENDIF.
*************************************Deleting Now***********
SORT lt_hier_level BY level DESCENDING.
LOOP AT lt_hier_level INTO ls_hier_level.
max_level = ls_hier_level-level.
EXIT.
ENDLOOP.
SORT lt_hier_level BY level ASCENDING.
LOOP AT lt_hier_level INTO ls_hier_level WHERE level EQ 0.
ls_hier_level-path = '1.ENTRIES.1'.
ls_hier_level-parent_path = '1.ENTRIES.1'.
MODIFY lt_hier_level FROM ls_hier_level.
ENDLOOP.
************************New design to Generate Path and Parent path
lv_cnt = 0.
temp_level = 1.
SORT lt_hier_level BY object_key ASCENDING.
LOOP AT lt_hier_level INTO ls_hier_level WHERE level EQ 1.
lv_cnt = lv_cnt + 1.
lv_parent_path = '1.ENTRIES.1'.
ls_hier_level-parent_path = lv_parent_path.
pos = lv_cnt.
CONCATENATE lv_parent_path separator 'SUB_ENTRIES' separator pos INTO lv_path.
ls_hier_level-path = lv_path.
MODIFY lt_hier_level FROM ls_hier_level.
ENDLOOP.
temp_level = 1.
lv_cnt = 0.
*********************Need to call this for each level ***************************
WHILE temp_level LT max_level.
CLEAR lt_pred.
CLEAR ls_pred.
LOOP AT lt_hier_level INTO ls_hier_level WHERE level EQ temp_level.
ls_pred-parent = ls_hier_level-object_key.
ls_pred-path = ls_hier_level-path.
APPEND ls_pred TO lt_pred.
ENDLOOP.
SORT lt_pred BY parent.
DELETE ADJACENT DUPLICATES FROM lt_pred.
LOOP AT lt_pred INTO ls_pred.
lv_cnt = 0.
LOOP AT lt_hier_level INTO ls_hier_level WHERE predecessor EQ ls_pred-parent.
lv_cnt = lv_cnt + 1.
lv_parent_path = ls_pred-path.
ls_hier_level-parent_path = lv_parent_path.
lv_path = ''.
pos = lv_cnt.
CONCATENATE lv_parent_path separator 'SUB_ENTRIES' separator pos INTO lv_path.
ls_hier_level-path = lv_path.
MODIFY lt_hier_level FROM ls_hier_level.
ENDLOOP.
ENDLOOP.
temp_level = temp_level + 1.
ENDWHILE.
LOOP AT lt_hier_level INTO ls_hier_level.
LOOP AT lt_hier_return INTO ls_hier_return.
IF ls_hier_level-object_key = ls_hier_return-object_key.
MOVE-CORRESPONDING ls_hier_level TO ls_hier_return.
MODIFY lt_hier_return FROM ls_hier_return.
ENDIF.
ENDLOOP.
ENDLOOP.
SORT lt_hier_return BY path ASCENDING.
**************************Delete the extra first character returned by PM_HIERARCHY_CALL******
LOOP AT lt_hier_return INTO ls_hier_return.
IF ls_hier_return-object_key(1) = 'T'.
SHIFT ls_hier_return-object_key BY 1 PLACES.
lv_object_key = ls_hier_return-object_key.
lv_funcloc_ext = lv_object_key.
CALL FUNCTION 'CONVERSION_EXIT_TPLNR_OUTPUT'
EXPORTING
input = lv_funcloc_ext
IMPORTING
output = lv_funcloc.
lv_int_obj_key = lv_funcloc.
ls_hier_return-object_key = lv_int_obj_key.
ELSEIF ls_hier_return-object_key(1) = 'E'.
SHIFT ls_hier_return-object_key BY 1 PLACES.
lv_object_key = ls_hier_return-object_key.
obj_len = strlen( lv_object_key ).
IF obj_len GE 18.
lv_object_key = lv_object_key+0(18).
ENDIF.
wd_comp_controller->conv_ext_2_int(
EXPORTING
iv_object_key_ext = lv_object_key " String
iv_object_type = 'EQUI' " String
IMPORTING
ev_object_key = lv_int_obj_key " String
SHIFT lv_int_obj_key LEFT DELETING LEADING '0'.
ls_hier_return-object_key = lv_int_obj_key.
ELSE.
SHIFT ls_hier_return-object_key BY 1 PLACES.
lv_object_key = ls_hier_return-object_key.
obj_len = strlen( lv_object_key ).
IF obj_len GE 18.
lv_object_key = lv_object_key+0(18).
ENDIF.
SHIFT lv_object_key LEFT DELETING LEADING '0'.
ls_hier_return-object_key = lv_object_key.
ENDIF.
MODIFY lt_hier_return FROM ls_hier_return TRANSPORTING object_key object_key.
ENDLOOP.
LOOP AT lt_hier_level INTO ls_hier_level.
IF ls_hier_level-object_key(1) = 'T'.
SHIFT ls_hier_level-object_key BY 1 PLACES.
lv_object_key = ls_hier_level-object_key.
lv_funcloc_ext = lv_object_key.
CALL FUNCTION 'CONVERSION_EXIT_TPLNR_OUTPUT'
EXPORTING
input = lv_funcloc_ext
IMPORTING
output = lv_funcloc.
lv_int_obj_key = lv_funcloc.
ls_hier_level-object_key = lv_int_obj_key.
ELSEIF ls_hier_level-object_key(1) = 'E'.
SHIFT ls_hier_level-object_key BY 1 PLACES.
lv_int_obj_key = ls_hier_level-object_key.
obj_len = strlen( lv_int_obj_key ).
IF obj_len GE 18.
lv_int_obj_key = lv_int_obj_key+0(18).
ENDIF.
wd_comp_controller->conv_ext_2_int(
EXPORTING
iv_object_key_ext = lv_int_obj_key " String
iv_object_type = 'EQUI' " String
IMPORTING
ev_object_key = lv_int_obj_key " String
SHIFT lv_int_obj_key LEFT DELETING LEADING '0'.
ls_hier_level-object_key = lv_int_obj_key.
ELSE.
SHIFT ls_hier_level-object_key BY 1 PLACES.
lv_int_obj_key = ls_hier_level-object_key.
obj_len = strlen( lv_int_obj_key ).
IF obj_len GE 18.
lv_int_obj_key = lv_int_obj_key+0(18).
ENDIF.
SHIFT lv_int_obj_key LEFT DELETING LEADING '0'.
ls_hier_level-object_key = lv_int_obj_key.
ENDIF.
MODIFY lt_hier_level FROM ls_hier_level TRANSPORTING object_key object_key.
ENDLOOP.
*********************Getinfo if root node else call Get_Children_Info to generate the structure as well*******
IF lv_path EQ '1.ENTRIES.1'.
element = wd_context->path_get_element( lv_path ).
navigate from <ENTRIES> to <SUB_ENTRIES> via lead selection
node_sub_entries = element->get_child_node( name = 'SUB_ENTRIES' ).
element->get_attribute( EXPORTING name = 'OBJECT_KEY'
IMPORTING value = item_object_key ).
element->get_attribute( EXPORTING name = `OBJECT_TYPE`
IMPORTING value = item_object_type ).
****************Get Info of Technical Objects*************
wd_comp_controller->get_children_info(
EXPORTING
iv_lt_list = lt_hier_return " Rplm_Tt_Mt_Struc
iv_path = ''
iv_hier_level = lt_hier_level
IMPORTING
ev_lt_full = lt_hier_return " Rplm_Tt_Mt_Struc
Create the strcuture by binding the entries to Node which is bound to the table
element = wd_context->path_get_element( lc_path ).
Get children node
node_sub_entries = element->get_child_node( 'SUB_ENTRIES' ).
CALL METHOD node_sub_entries->bind_table
EXPORTING
new_items = lt_hier_return
set_initial_elements = abap_true.
@TODO handle not set lead selection
IF ( node_entries IS INITIAL ).
ENDIF.
lv_temp = 1.
***************Sort the LT_HIER_TABLE appropriately ******
LOOP AT lt_hier_return INTO ls_hier_return .
MOVE-CORRESPONDING ls_hier_return TO ls_hier_return_sort.
ls_hier_return_sort-path_length = strlen( ls_hier_return_sort-path ).
APPEND ls_hier_return_sort TO lt_hier_return_sort.
ENDLOOP.
SORT lt_hier_return_sort BY path_length ASCENDING path ASCENDING.
CLEAR lt_hier_return.
LOOP AT lt_hier_return_sort INTO ls_hier_return_sort.
MOVE-CORRESPONDING ls_hier_return_sort TO ls_hier_return.
APPEND ls_hier_return TO lt_hier_return.
ENDLOOP.
*wd_comp_controller->gv_master_data = lt_hier_return.
LOOP AT lt_hier_return INTO ls_hier_return.
lv_path = ls_hier_return-path.
lc_path = ls_hier_return-parent_path.
IF lv_path NE '1.ENTRIES.1'.
element = wd_context->path_get_element( lc_path ).
Get children node
node_sub_entries = element->get_child_node( 'SUB_ENTRIES' ).
Now, create the children elements
element->get_attribute( EXPORTING name = 'OBJECT_KEY'
IMPORTING value = ls_hier_level-predecessor ).
Create the strcuture by binding the entries to Node which is bound to the table
CALL METHOD node_sub_entries->bind_structure
EXPORTING
new_item = ls_hier_return
set_initial_elements = abap_false.
ENDIF.
ENDLOOP.
Only when a new level is reached we create one more child node
else we attach our elements to same child node
element = wd_context->path_get_element( item_path ).
Get children node
element->set_attribute(
value = abap_false
name = 'IS_EXPANDED' ).
ENDIF.
navigate from <CONTEXT> to <GENERAL> via lead selection
node_general = wd_context->get_child_node( name = wd_this->wdctx_general ).
get element via lead selection
elem_general = node_general->get_element( ).
get single attribute
elem_general->set_attribute(
name = `COLLAPSE_VISIBILITY`
value = abap_false ).
node_selected_entry = wd_context->get_child_node( name = if_structure_view_new=>wdctx_selected_entry ).
get element via lead selection
elem_selected_entry = node_selected_entry->get_element( ).
get single attribute
elem_selected_entry->set_attribute(
name = `OBJECT_KEY`
value = '' ).
elem_selected_entry->set_attribute(
name = `OBJECT_TYPE`
value = '' ).
get element via lead selection
elem_context = wd_context->get_element( ).
get single attribute
elem_context->set_attribute(
name = `EXPAND_ALL`
value = abap_false ).
wd_this->enable_buttons(
endmethod. -
Dynamic Table UI Element with different data type for each cell
Hi Experts,
I have a problem with a dynamic Table UI Element in Web Dynpro ABAP. I have the following coding:
METHOD set_col_row .
TYPE-POOLS: icon.
DATA:
lv_node TYPE REF TO if_wd_context_node,
lv_node_info TYPE REF TO if_wd_context_node_info,
lv_element TYPE REF TO if_wd_context_element,
lt_attributes TYPE wdr_context_attr_info_map,
lv_table TYPE REF TO cl_wd_table,
lv_table_column TYPE REF TO cl_wd_table_column,
lv_text_view TYPE REF TO cl_wd_text_view,
lv_image TYPE REF TO cl_wd_image,
lv_text_edit TYPE REF TO cl_wd_text_edit,
lv_header TYPE REF TO cl_wd_caption,
attribute LIKE LINE OF lt_attributes,
lv_index TYPE string,
lv_cur_row TYPE i,
path TYPE string,
lv_value TYPE string,
attr_name TYPE string,
l_trc_point_id TYPE string,
l_num_cols TYPE string,
l_num_rows TYPE string,
lv_text TYPE string,
lv_index2 TYPE i,
lr_ress_selections TYPE REF TO /its/di_2_cpr_ress_selections,
lt_comp_tab TYPE cl_abap_structdescr=>component_table,
ls_comp_tab LIKE LINE OF lt_comp_tab,
lv_count TYPE i,
lv_col_count TYPE i,
lv_col_count_read TYPE i,
lv_index_read TYPE i,
lv_num_cols_minus_1 TYPE i,
lv_bind_lv_value TYPE string,
wd_standard_cell TYPE REF TO cl_wd_table_standard_cell,
lv_data_count TYPE i,
lv_data_count_str TYPE string,
wd_table_column TYPE REF TO cl_wd_table_column,
lv_column_id TYPE string.
FIELD-SYMBOLS:
TYPE ANY.
Instanz der Klasse /ITS/DI_2_CPR_RESS_SELECTIONS
lr_ress_selections = /its/di_2_cpr_ress_selections=>factory( ).
ASSIGN lr_ress_selections->gr_table->* TO gt_comp_tab.
ls_comp_tab-name = 'SUMME'.
APPEND ls_comp_tab TO lt_comp_tab.
ls_comp_tab-name = 'CELL_VARIANT'.
APPEND ls_comp_tab TO lt_comp_tab.
CLEAR ls_comp_tab.
l_num_rows = num_rows + 1.
CONDENSE l_num_rows.
l_num_cols = num_columns + 1.
CONDENSE l_num_cols.
UI-Element 'TABLE'
lv_table ?= wd_this->m_view->get_element( 'TBL_TABLE' ).
lv_table->remove_all_columns( ).
Kontext-Knoten 'TABLE'
lv_node = wd_context->get_child_node( 'TABLE' ).
lv_node_info = lv_node->get_node_info( ).
lv_node_info->remove_dynamic_attributes( ).
attribute-type_name = 'STRING'.
lv_num_cols_minus_1 = num_columns - 1.
Für jede Spalte einmal tun
DO lv_num_cols_minus_1 TIMES.
lv_index = sy-index + 1.
CONDENSE lv_index.
lv_table_column = cl_wd_table_column=>new_table_column( ).
lv_column_id = lv_table_column->id.
Spaltenüberschriften setzen
IF lv_index EQ 1. "Beim ersten Durchlauf --> erste Spalte = "Ressourcen"
lv_text = text-010.
sy-index = 0.
ELSE. "Danach für jede weitere Spalte eine Zeile aus der gt_comp_tab nehmen
lv_index_read = lv_index - 1.
READ TABLE lt_comp_tab INDEX lv_index_read INTO ls_comp_tab.
lv_text = ls_comp_tab-name.
lv_header = cl_wd_caption=>new_caption( text = lv_text ).
lv_table_column->set_header( lv_header ).
ENDIF.
CONCATENATE 'TABLE.A' lv_index INTO path.
lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path ).
lv_table_column->set_table_cell_editor( lv_text_view ).
lv_table_column->bind_selected_cell_variant( 'TABLE.CELL_VARIANT' ).
lv_table->add_column( lv_table_column ).
wd_table_column ?= wd_this->m_view->get_element( lv_column_id ).
*****************Test Cell Variant*************************************************
IF lv_index GT 1.
LOOP AT .
IF sy-tabix EQ lv_cur_row.
Name zuweisen
ASSIGN COMPONENT 'NAME' OF STRUCTURE .
Zuweisen ob Blatt oder nicht
lv_element->set_attribute( name = 'NAME' value = lv_value ).
ASSIGN COMPONENT 'IS_LEAF' OF STRUCTURE set_attribute( name = attr_name value = lv_value ).
ENDIF.
ENDLOOP.
Now my problem is, that I need for every ROW of my table UI Element a different cell editor. I know how to change it for the column. But is not my issue. I want to have images (traffic lights red and green) in some rows. The other rows should have numbers. The coding works, so that I have all the data at the right place in my table, only the images are shown as a string, because the cells of these rows have the cell editor Text_View. I tried something with cell variants (with cl_wd_table_standard_cell), but it was not possible for me to get a cell variant "image" in these cells/rows were I need it.
I hope you understand my problem and now what to do here.
Thanks a lot in advance.
Best Regards,
IngmarHi Experts, I have a problem with a dynamic Table UI Element in Web Dynpro ABAP. I have the following coding: METHOD set_col_row . TYPE-POOLS: icon. DATA: lv_node TYPE REF TO if_wd_context_node, lv_node_info TYPE REF TO if_wd_context_node_info, lv_element TYPE REF TO if_wd_context_element, lt_attributes TYPE wdr_context_attr_info_map, lv_table TYPE REF TO cl_wd_table, lv_table_column TYPE REF TO cl_wd_table_column, lv_text_view TYPE REF TO cl_wd_text_view, lv_image TYPE REF TO cl_wd_image, lv_text_edit TYPE REF TO cl_wd_text_edit, lv_header TYPE REF TO cl_wd_caption, attribute LIKE LINE OF lt_attributes, lv_index TYPE string, lv_cur_row TYPE i, path TYPE string, lv_value TYPE string, attr_name TYPE string, l_trc_point_id TYPE string, l_num_cols TYPE string, l_num_rows TYPE string, lv_text TYPE string, lv_index2 TYPE i, lr_ress_selections TYPE REF TO /its/di_2_cpr_ress_selections, lt_comp_tab TYPE cl_abap_structdescr=>component_table, ls_comp_tab LIKE LINE OF lt_comp_tab, lv_count TYPE i, lv_col_count TYPE i, lv_col_count_read TYPE i, lv_index_read TYPE i, lv_num_cols_minus_1 TYPE i, lv_bind_lv_value TYPE string, wd_standard_cell TYPE REF TO cl_wd_table_standard_cell, lv_data_count TYPE i, lv_data_count_str TYPE string, wd_table_column TYPE REF TO cl_wd_table_column, lv_column_id TYPE string. FIELD-SYMBOLS: LIKE LINE OF lt_attributes, TYPE ANY TABLE, TYPE ANY, TYPE ANY, TYPE ANY. * Instanz der Klasse /ITS/DI_2_CPR_RESS_SELECTIONS lr_ress_selections = /its/di_2_cpr_ress_selections=>factory( ). ASSIGN lr_ress_selections->gr_table->* TO . lt_comp_tab = lr_ress_selections->gt_comp_tab. ls_comp_tab-name = 'SUMME'. * APPEND ls_comp_tab TO lt_comp_tab. * ls_comp_tab-name = 'CELL_VARIANT'. APPEND ls_comp_tab TO lt_comp_tab. CLEAR ls_comp_tab. l_num_rows = num_rows + 1. CONDENSE l_num_rows. l_num_cols = num_columns + 1. CONDENSE l_num_cols. * UI-Element 'TABLE' lv_table ?= wd_this->m_view->get_element( 'TBL_TABLE' ). lv_table->remove_all_columns( ). * Kontext-Knoten 'TABLE' lv_node = wd_context->get_child_node( 'TABLE' ). lv_node_info = lv_node->get_node_info( ). lv_node_info->remove_dynamic_attributes( ). attribute-type_name = 'STRING'. lv_num_cols_minus_1 = num_columns - 1. * Für jede Spalte einmal tun DO lv_num_cols_minus_1 TIMES. lv_index = sy-index + 1. CONDENSE lv_index. lv_table_column = cl_wd_table_column=>new_table_column( ). lv_column_id = lv_table_column->id. * Spaltenüberschriften setzen IF lv_index EQ 1. "Beim ersten Durchlauf --> erste Spalte = "Ressourcen" lv_text = text-010. sy-index = 0. ELSE. "Danach für jede weitere Spalte eine Zeile aus der gt_comp_tab nehmen lv_index_read = lv_index - 1. READ TABLE lt_comp_tab INDEX lv_index_read INTO ls_comp_tab. lv_text = ls_comp_tab-name. lv_header = cl_wd_caption=>new_caption( text = lv_text ). lv_table_column->set_header( lv_header ). ENDIF. CONCATENATE 'TABLE.A' lv_index INTO path. lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path ). lv_table_column->set_table_cell_editor( lv_text_view ). lv_table_column->bind_selected_cell_variant( 'TABLE.CELL_VARIANT' ). lv_table->add_column( lv_table_column ). wd_table_column ?= wd_this->m_view->get_element( lv_column_id ). ******************Test Cell Variant************************************************** IF lv_index GT 1. LOOP AT ASSIGNING . ASSIGN COMPONENT 'TYPE' OF STRUCTURE TO . ADD 1 TO lv_data_count. lv_data_count_str = lv_data_count. CONCATENATE 'A' lv_index lv_data_count_str INTO path. wd_standard_cell = cl_wd_table_standard_cell=>new_table_standard_cell( view = wd_this->m_view variant_key = 'FLDATE' ). IF = '01' OR = '04'. lv_image = cl_wd_image=>new_image( bind_source = path view = wd_this->m_view ). wd_standard_cell->set_editor( lv_image ). wd_standard_cell->set_cell_design( '01' ). ELSE. lv_text_view = cl_wd_text_view=>new_text_view( bind_text = path view = wd_this->m_view ). wd_standard_cell->set_editor( lv_text_view ). wd_standard_cell->set_cell_design( '02' ). ENDIF. wd_table_column->add_cell_variant( wd_standard_cell ). ENDLOOP. ENDIF. ************************************************************************************* CONCATENATE 'A' lv_index INTO attribute-name. lv_node_info->add_attribute( attribute ). ENDDO. DO num_rows TIMES." Für jede Zeile einmal tun lv_cur_row = sy-index. lv_element = lv_node->create_element( ). lv_node->bind_element( new_item = lv_element set_initial_elements = abap_false ). DO l_num_cols TIMES. ADD 1 TO lv_col_count. IF lv_count LT 1. LOOP AT ASSIGNING . IF sy-tabix EQ lv_cur_row. * Name zuweisen ASSIGN COMPONENT 'NAME' OF STRUCTURE TO . "NAME lv_value = . * Zuweisen ob Blatt oder nicht lv_element->set_attribute( name = 'NAME' value = lv_value ). ASSIGN COMPONENT 'IS_LEAF' OF STRUCTURE TO . "NAME lv_value = . lv_element->set_attribute( name = 'IS_LEAF' value = lv_value ). ENDIF. ENDLOOP. ENDIF. IF lv_count GT 0. lv_col_count_read = lv_col_count - 1. lv_index = sy-index. LOOP AT ASSIGNING . IF sy-tabix EQ lv_cur_row. CLEAR ls_comp_tab. READ TABLE lt_comp_tab INDEX lv_col_count_read INTO ls_comp_tab. ASSIGN COMPONENT ls_comp_tab-name OF STRUCTURE TO . lv_value = . CONDENSE lv_index. CONCATENATE 'A' lv_index INTO attr_name. lv_element->set_attribute( name = attr_name value = lv_value ). ENDIF. ENDLOOP. ENDIF. lv_count = lv_count + 1. ENDDO. CLEAR lv_col_count. CLEAR lv_count. ENDDO. ENDMETHOD. I definied my table in Layout Tab of the View and create here in thos method dynamicly my columns. lv_table_column = cl_wd_table_column=>new_table_column( ). . . lv_table->add_column( lv_table_column ). In I have my data that should be shown later in my table. So I create for each row in this fieldsymbol in a loop: lv_element = lv_node->create_element( ). lv_node->bind_element( new_item = lv_element set_initial_elements = abap_false ). Later I fill every cell in my table with a different value with this loop: LOOP AT ASSIGNING . IF sy-tabix EQ lv_cur_row. CLEAR ls_comp_tab. READ TABLE lt_comp_tab INDEX lv_col_count_read INTO ls_comp_tab. ASSIGN COMPONENT ls_comp_tab-name OF STRUCTURE TO . lv_value = . CONDENSE lv_index. CONCATENATE 'A' lv_index INTO attr_name. lv_element->set_attribute( name = attr_name value = lv_value ). ENDIF. ENDLOOP. Now my problem is, that I need for every ROW of my table UI Element a different cell editor. I know how to change it for the column. But is not my issue. I want to have images (traffic lights red and green) in some rows. The other rows should have numbers. The coding works, so that I have all the data at the right place in my table, only the images are shown as a string, because the cells of these rows have the cell editor Text_View. I tried something with cell variants (with cl_wd_table_standard_cell), but it was not possible for me to get a cell variant "image" in these cells/rows were I need it. I hope you understand my problem and now what to do here. Thanks a lot in advance. Best Regards, Ingmar
Maybe you are looking for
-
Can I connect a regular phone with a RTX Dualphone...
Hi, I just decided to switch from vonage to skype number and was wondering: If i purchase the Dualphone 4088, will I be able to plug in a regular phone and use it for regular calls? I'd like to have 2 phones but i'm trying to decide if I just need on
-
OS X Lion Kernel is 32bit, processor is 64bit?
It appears that for whatever reason, the kernel on my Mac is 32bit/i386, but the architecture is 64bit: Darwin system.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:48:32 PST 2012; root:xnu-1699.24.23~1/RELEASE_I386 i386 Though the kernel i
-
Master Details form (LOV based on Detail Column of Join Condition)
I have created a master detail form where user_id is joining master and details. I have created one dynamic lov based on child user_id in detail block to diplay all user who works under current user. Problem : When i want to select Insert detail acti
-
"Network transition in LDAPv3 plugin returned error -14279"
Came in this morning an booted up, and it took forever, and hung like it dows 25% of the time, and dows not show network home user login accounts. Rebooted, same thing, usually this solves it. Looked at DirectoryServices.error.log on my machine (clie
-
[FL8] codificación URF-8
Hola de nuevo foro. En un formulario de correo, todo me funciona correctamente excepto el texto del mensaje que recibo y me llega algo como ésto: Sr./Sra. D./Dña : el nombre que el cliente escriba E-mail de contacto : el correo electrónico que que cl