Array as class attribute?

I'm currently in the process of learning Objective-C and Cocoa, however I've run into an issue with some of my code.
I want to have an array that other objects will be able to access from my main class, so I set it to be an attribute of that class in the interface: NSObject section of my class header with the following line of code:
NSMutableArray *qArray;
The main issue I'm getting with this is that although the array can be accessed properly, I'm not sure how to initialise it. I used the following code that seemed to work, but only when called from the same IBAction, if sent from another control or menu then it would crash to the debugger:
qArray = [NSMutableArray array];
I'm guessing that qArray is being destroyed after the IBAction is finished, but how would I initialise it otherwise?

The message +array is called a "convenience method", it returns an auto-released instance of the class, here it's an NSArray. So you have two solution, one one hand you simply use the alloc/init methods :
qArray = [[NSArray allocWithZone: [self zone]] init]; // you can use the simple +alloc method if you want.
Or you can retain the object returned by +array, like that :
qArray = [[NSArray array] retain];
In both cases, you need at the end to send the object a -release or -autorelease message :
[qArray release];
NB : the brackets might be not displayed in that message.

Similar Messages

  • Store an Array of Classes e.g. Order / Line Items example

    Hello, I am having trouble storing an array of classes, they all end up having the same value.
    Consider the following simple class definition:
    Class Order
    private LineItem[] lineItems;
    Class LineItem(amount, price)
    private int amount;
    private float price;
    Consider the following pseudo code as part of the constructor of class order (to fill the array with a bunch of LineItems):
    for x = 1 to 10
    lineItems[x] = new LineItem(amount, price);
    however all lineItems[x] have the same LineItem
    any ideas?

    i posted the design since its a bit more complicated then my summarized version, but at any rate i will post the full solution for those who want to view either or...
    basically this takes an XML field and creates an object Order which has some attributes plus an array of Line Item objects.
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import org.dom4j.Node;
    import org.dom4j.Document;
    public class SiebelOrder
      private String accountId;
      private String backOfficeOrderNumber;
      private String contactFirstName;
      private String contactId;
      private String contactLastName;
      private String currencyCode;
      private String description;
      private String entryAssociate;
      private String legalEntity;
      private String orderRevenue;
      private String orderDate;
      private String orderNumber;
      private String orderType;
      private String orderTypeId;
      private String primaryOrganization;
      private String primaryServiceRegion;
      private String primaryShipToAddress;
      private String PrimaryShipToAddressId;
      private String PrimaryShipToCity;
      private String PrimaryShipToCountry;
      private String PrimaryShipToPostalCode;
      private String PrimaryShipToState;
      private String RegionAddress;
      private String RegionAddressId;
      private String RegionCity;
      private String RegionCountry;
      private String RegionPostalCode;
      private String RegionState;
      private String Revision;
      private String SalesRecognizedDate;
      private String status;
      private String taxExempt;
      private String taxExemptNumber;
      private String taxExemptReason;
      private SiebelLineItem[] lineItems;
      protected SiebelOrder()
        //default constructor
      protected SiebelOrder(Node pOrderNode)
        //gets the attribute by using an xpath query of the given node
        accountId = pOrderNode.valueOf("//AccountId/text()");
        backOfficeOrderNumber = pOrderNode.valueOf("//BackOfficeOrderNumber/text()");
        contactFirstName = pOrderNode.valueOf("//ContactFirstName/text()");
        contactId = pOrderNode.valueOf("//ContactId/text()");
        contactLastName = pOrderNode.valueOf("//ContactLastName/text()");
        currencyCode = pOrderNode.valueOf("//CurrencyCode/text()");
        description = pOrderNode.valueOf("//Description/text()");
        entryAssociate = pOrderNode.valueOf("//EntryAssociateEMP/text()");
        legalEntity = pOrderNode.valueOf("//LegalntityEMP/text()");
        orderRevenue = pOrderNode.valueOf("//OrderRevenueEMP/text()");
        orderDate = pOrderNode.valueOf("//OrderDate/text()");
        orderNumber = pOrderNode.valueOf("//OrderNumber/text()");
        orderType = pOrderNode.valueOf("//OrderType/text()");
        orderTypeId = pOrderNode.valueOf("//OrderTypeId/text()");
        primaryOrganization = pOrderNode.valueOf("//PrimaryOrganization/text()");
        primaryServiceRegion = pOrderNode.valueOf("//PrimaryServiceRegionEMP/text()");
        primaryShipToAddress = pOrderNode.valueOf("//PrimaryShipToAddress/text()");
        PrimaryShipToAddressId = pOrderNode.valueOf("//PrimaryShipToAddressId/text()");
        PrimaryShipToCity = pOrderNode.valueOf("//PrimaryShipToCity/text()");
        PrimaryShipToCountry = pOrderNode.valueOf("//PrimaryShipToCountry/text()");
        PrimaryShipToPostalCode = pOrderNode.valueOf("//PrimaryShipToPostalCode/text()");
        PrimaryShipToState = pOrderNode.valueOf("//PrimaryShipToState/text()");
        RegionAddress = pOrderNode.valueOf("//RegionAddress/text()");
        RegionAddressId = pOrderNode.valueOf("//RegionAddressId/text()");
        RegionCity = pOrderNode.valueOf("//RegionCity/text()");
        RegionCountry = pOrderNode.valueOf("//RegionCountry/text()");
        RegionPostalCode = pOrderNode.valueOf("//RegionPostalCode/text()");
        RegionState = pOrderNode.valueOf("//RegionState/text()");
        Revision = pOrderNode.valueOf("//RegionRevision/text()");
        SalesRecognizedDate = pOrderNode.valueOf("//SalesRecognizedDateEMP/text()");
        status = pOrderNode.valueOf("//Status/text()");
        taxExempt = pOrderNode.valueOf("//TaxExempt/text()");
        taxExemptNumber = pOrderNode.valueOf("//TaxExemptNumber/text()");
        taxExemptReason = pOrderNode.valueOf("//TaxExemptReason/text()");
        // ----- create line items -----
        //queries the order node using xpath and returns it as a list of line item nodes
        List lineItemList = pOrderNode.selectNodes("//OrderEntry-LineItemsEmp");
        //sizes the array to the number of line items
        lineItems = new SiebelLineItem[lineItemList.size()];
        //update the array to be a list of blank lineitems
        for(int i=0; i < lineItemList.size(); i++)
          lineItems[i] = new SiebelLineItem();
        //store the lineitem details in each array item
        int i = 0;
        for (Iterator iter = lineItemList.iterator(); iter.hasNext(); )
          Node lineItemNode = (Node) iter.next();   
          //  ALL lineItems[i] ARE THE SAME VALUE
          lineItems.setLineDetails(lineItemNode);
    i++;
    import java.util.HashMap;
    import java.util.Map;
    import org.dom4j.Document;
    import org.dom4j.Node;
    public class SiebelLineItem
        private String actualSalesPrice;
        private String costProduct;
        private String ESRPLabor;
        private String inactiveFlag;
        private String installationMethod;
        private String integrationId;
        private String laborOptionFlag;
        private String lineItemType;
        private String lineNumber;
        private String lineSequenceNumber;
        private String lineStatus;
        private String orderHeaderId;
        private String product;
        private String productId;
        private String productSeries;
        private String productStyle;
        private String servicePartFlag;
        private String taxRate;
        private String taxType;
        private String UOMLine;
        private String UOMQuantity;
        private String vendorCode;
        private String vendorName;
      protected SiebelLineItem()
        //default constructor
      protected void setLineDetails(Node pLineItemNode)
        //gets the attribute by using an xpath query of the given node
        actualSalesPrice = pLineItemNode.valueOf("//ActualSalesPriceEMP/text()");   
        costProduct = pLineItemNode.valueOf("//CostProductEMP/text()");
        ESRPLabor = pLineItemNode.valueOf("//ESRPLaborEMP/text()");
        inactiveFlag = pLineItemNode.valueOf("//InactiveFlagEMP/text()");
        installationMethod = pLineItemNode.valueOf("//InstallationMethodEMP/text()");
        integrationId = pLineItemNode.valueOf("//IntegrationIdEMP/text()");
        laborOptionFlag = pLineItemNode.valueOf("//LaborOptionFlagEMP/text()");   
        lineItemType = pLineItemNode.valueOf("//LineItemTypeEMP/text()"); 
        lineNumber = pLineItemNode.valueOf("//LineNumberEMP/text()");
        lineSequenceNumber = pLineItemNode.valueOf("//LineSequenceNumberEMP/text()");
        lineStatus = pLineItemNode.valueOf("//LineStatusEMP/text()");
        orderHeaderId = pLineItemNode.valueOf("//OrderHeaderId/text()");
        product = pLineItemNode.valueOf("//Product/text()");
        productId = pLineItemNode.valueOf("//ProductId/text()");
        productSeries = pLineItemNode.valueOf("//ProductSeriesEMP/text()");
        productStyle = pLineItemNode.valueOf("//ProductStyleEMP/text()");
        servicePartFlag = pLineItemNode.valueOf("//ServicePartFlagEMP/text()");
        taxRate = pLineItemNode.valueOf("//TaxRateEMP/text()");
        taxType = pLineItemNode.valueOf("//TaxTypeEMP/text()");
        UOMLine = pLineItemNode.valueOf("//UOMLineEMP/text()");
        UOMQuantity = pLineItemNode.valueOf("//UOMQuantityEMP/text()");
        vendorCode = pLineItemNode.valueOf("//VendorCodeEMP/text()");
        vendorName = pLineItemNode.valueOf("//VendorNameEMP/text()"); 

  • Page Attributes and Application Class Attributes

    Hi, everyone,
    I am quite new to BSP.
    I have a question here:
    what is the difference between page attributes and application class attributes of a bsp application? As they are both global attributes, there seems to be no big difference when we use them.
    thanks a lot.
    Fan

    Hi Fan,
    a BSP application can be made up of many pages.
    A page attribute is visible only in the page it is associated with.
    Attributes of the application class are visible from every page in that application.
    Cheers
    Graham Robbo

  • Download Global Class attributes

    Hi...
          I want to download the global class attributes into an excel. when i checked the menu there is no such option.. Is that possible to do.. Can anyone guide me...
    Thanks in advance.
    Kalpanashri Rajendran.

    Hi,
    Assuming you are asking specifically about the global class "Attributes" and not all information about the global class itself.  To get the "Attributes" in a spreadsheet you can try this work-around:
    1. Run transaction SE84 Repository Info System.
    2. Expand the "Class Library" branch.
    3. Double-click the "Attributes" node.
    4. Enter your global class name and run the search.
    5. Once the list of attributes is displayed, choose menu path System -> List -> Save -> Local File.
    6. Choose "Spreadsheet" format in the popup.
    7. Give a file path and name for your spreadsheet.
    8. You should now have a spreadsheet with all the "Attributes" of your global class.
    Best Regards,
    Jamie

  • Field-symbols as class attribute

    Hi Fellas,
    Is there a way we can define a field-symbols as a class attribute ? My requirement is that i am dynamically constructing a structure at runtime in my model class and binding the component of this structure to my view fields. I am able to create the structure which is basically ref to cl_abap_structdescr and the problem is when i am binding to the model attribute, i need this to be a structure so that i can address the components as "//model/structure.component".
    Please let me know how we can define a field-symbol as a class attribute.
    Cheers,
    Ram.

    Hi Ram,
    Field-Symbol as class attribute is not possible. Your way to do this by REF TO DATA is the correct way for that.
    By default data binding is only possible like this:
    Simple field attribute
    value=”//<model>/<field name>”
    Structure attribute
    value=”//<model>/<structure name>.<field name>”
    Table attribute
    value=”//<model>/<table name>[<line index].<field name>”
    If you want to bind to your data reference you have to implement your own getter and setter methods. Read this <a href="http://help.sap.com/saphelp_nw70/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm">http://help.sap.com/saphelp_nw70/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm</a> for further information. In addition to that, you have to implement your own GET_M_S_xxx to return metadata of your structure. By doing all this it is possible to implement a completely dynamic data binding. In the view it looks like the regular Structure attribute: value=”//<model>/<data-ref name>.<field name>”
    Regards,
    Thilo

  • How to insert values into an array of class

    Hello everyone,
    I need help in inserting values into an array of class, which i have read from a file.
    Length of the array is 5. I should insert values one by one into that array.
    If the array is full (if count = 5), then I should split the array into 2 arrays
    and adjust the values to left and right with median.
    I'm getting an ArrayBoundException .. can anybody help me out ?
    Thanks in advance
    Here is my code..........
    import java.util.*;
    import java.io.*;
    public class Tree
         static String second;
         static String first;
         static int count = 5;
         public void insert(int f1,int s1, int c)
              if(c!=0)
                   Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                   for(int i = 0; i<=4;i++)
                        rec.x = f1;
                        rec[i].y = s1;
              else
                   System.out.println("yes");
         public static void main(String[] args)
              Tree t = new Tree();
              try
                   FileReader fr = new FileReader("output.txt");           // open file
                   BufferedReader br = new BufferedReader(fr);
                   String s;
                   while((s = br.readLine()) != null)
                        StringTokenizer st = new StringTokenizer(s);
                        while(st.hasMoreTokens())
                             first = st.nextToken();
                             second = st.nextToken();
                        //     System.out.println("First-->"+first+" "+"Second-->"+second);
                        int fir = Integer.parseInt(first);
                        int sec = Integer.parseInt(second);
                        t.insert(fir, sec, count);                    
                   fr.close(); // close file           
              catch (IOException e)
    System.out.println("Can't read file");
    class Record
         public int x,y;

    Hi qwedwe.
    Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                     }Here is your error: you have an array of 4 Records, but you create and (try to) insert 5 Record-instances.... try:
    Record[] rec = new Record[c];
                   for (int i = 0; i < c; i++)
                          rec[i] = new Record(); 
                     }Regards,
    Norman

  • Array of class objects

    I was wondering how would you declare an array of class objects. Here is my situation:
    I'm working on a project dealing with bank accounts. Each customer has a specific ID and a balance. I have to handle transactions for each customer at different times, so I was thinking that I need an array of class objects; however, I dont know how to initialize them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz

    I was wondering how would you declare an array of
    class objects. Here is my situation:
    I'm working on a project dealing with bank accounts.
    Each customer has a specific ID and a balance. I have
    to handle transactions for each customer at different
    times, so I was thinking that I need an array of
    class objects; however, I dont know how to initialize
    them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz
    HAI
    Use the hashtable
    and store the classObject of each customer with the corresponding Id in it
    and whenever u want to recover a class match the Id and get the corresponding class
    that is the best way to solve ur problem
    Regards
    kamal

  • Jar files and Main-Class attribute

    Sorry, I know there are other topics regarding this argument but none of them helped me solving my problem.
    I've tried a thousand time in every possible way, but I still can't run my application from a jar file. I've got a package called client, whose main class is called Client. The package contains a sub-package called Icons. I've put everything into a jar file and added this manifest:
    Manifest version: 1.0
    Name: client/
    Sealed: True
    Main-Class: client.Client
    But it won't work. I've tried to erase the Sealed part, I've tried "Main-Class: Client" and also "client/Client", I've tried putting into the jar the client directory and I've tried omitting it, but the answer is always the same:
    Failed to load main-class header etc.
    Can anyone help me? Please, I'm almost desperate!
    Thanks

    Here's the verbose-mode description of what I did.
    jar -cfv client.jar clientaggiunto manifesto
    aggiunta in corso di: client/(in = 0) (out= 0)(archiviato 0%)
    aggiunta in corso di: client/.nbattrs(in = 767) (out= 310)(compresso 59%)
    aggiunta in corso di: client/Client.class(in = 533) (out= 340)(compresso 36%)
    aggiunta in corso di: client/Client.java(in = 288) (out= 140)(compresso 51%)
    aggiunta in corso di: client/ClientForm$1.class(in = 691) (out= 383)(compresso 44%)
    aggiunta in corso di: client/ClientForm$10.class(in = 678) (out= 380)(compresso 43%)
    aggiunta in corso di: client/ClientForm$11.class(in = 689) (out= 385)(compresso 44%)
    aggiunta in corso di: client/ClientForm$2.class(in = 686) (out= 379)(compresso 44%)
    aggiunta in corso di: client/ClientForm$3.class(in = 686) (out= 381)(compresso 44%)
    aggiunta in corso di: client/ClientForm$4.class(in = 686) (out= 380)(compresso 44%)
    aggiunta in corso di: client/ClientForm$5.class(in = 686) (out= 383)(compresso 44%)
    aggiunta in corso di: client/ClientForm$6.class(in = 718) (out= 399)(compresso 44%)
    aggiunta in corso di: client/ClientForm$7.class(in = 718) (out= 400)(compresso 44%)
    aggiunta in corso di: client/ClientForm$8.class(in = 718) (out= 399)(compresso 44%)
    aggiunta in corso di: client/ClientForm$9.class(in = 718) (out= 398)(compresso 44%)
    aggiunta in corso di: client/ClientForm.class(in = 33070) (out= 13510)(compresso 59%)
    aggiunta in corso di: client/ClientForm.form(in = 131398) (out= 4521)(compresso96%)
    aggiunta in corso di: client/ClientForm.java(in = 73435) (out= 6863)(compresso 90%)
    aggiunta in corso di: client/Icons/(in = 0) (out= 0)(archiviato 0%)
    aggiunta in corso di: client/Icons/brick.gif(in = 1044) (out= 1049)(compresso 0%)
    aggiunta in corso di: client/Icons/corpo.gif(in = 4011) (out= 3400)(compresso 15%)
    aggiunta in corso di: client/Icons/door.gif(in = 1092) (out= 1097)(compresso 0%)
    aggiunta in corso di: client/Icons/floor.gif(in = 1102) (out= 1107)(compresso 0%)
    aggiunta in corso di: client/Icons/mappa.gif(in = 20901) (out= 20575)(compresso 1%)
    aggiunta in corso di: client/Icons/paesaggio.gif(in = 18962) (out= 18603)(compresso 1%)
    aggiunta in corso di: client/Icons/sole.gif(in = 7063) (out= 6546)(compresso 7%)
    aggiunta in corso di: client/Icons/trap.gif(in = 1062) (out= 1067)(compresso 0%)
    aggiunta in corso di: client/Icons/void.gif(in = 842) (out= 847)(compresso 0%)
    aggiunta in corso di: client/Listener.class(in = 1869) (out= 1136)(compresso 39%)
    aggiunta in corso di: client/Listener.java(in = 2296) (out= 708)(compresso 69%)
    aggiunta in corso di: client/manifesto.txt(in = 62) (out= 58)(compresso 6%)
    aggiunta in corso di: client/ScorciatoieDialog$1.class(in = 740) (out= 391)(compresso 47%)
    aggiunta in corso di: client/ScorciatoieDialog$PopupListener.class(in = 1579) (out= 773)(compresso 51%)
    aggiunta in corso di: client/ScorciatoieDialog.class(in = 3524) (out= 1638)(compresso 53%)
    aggiunta in corso di: client/ScorciatoieDialog.form(in = 8500) (out= 910)(compresso 89%)
    aggiunta in corso di: client/ScorciatoieDialog.java(in = 5676) (out= 1222)(compresso 78%)
    jar umf mainclass.txt client.jar[NOTE: mainclass.txt only contains the line "Main-Class: client.Client"]
    java -jar client.jarFailed to load Main-Class manifest attribute from
    client.jar
    I've also tried to manually create a MANIFEST.MF file that only contained the following lines:
    Manifest Version: 1.0
    Main-Class: client.Client
    guess what was the result?
    java -jar client.jarException in thread "main" java.io.IOException: invalid manifest format
    at java.util.jar.Manifest.read(Manifest.java:193)
    at java.util.jar.Manifest.<init>(Manifest.java:52)
    at java.util.jar.JarFile.getManifest(JarFile.java:158)
    >
    the same procedure with the addition of "Name: client/" before the main-class attribute generated the usual "Failed to load Main-Class manifest attribute" result. So now what?!? I'm getting crazy....

  • 'ResourceDictionary' root element is a generic type and requires a x:Class attribute to support the x:TypeArguments attribute sp

    Error : 'ResourceDictionary' root element is a generic type and requires a x:Class attribute to support the x:TypeArguments attribute specified on the root element tag.
    Hi,
    I get this error when i include some namespaces in my ResourceDictionary to specify a Style for a custom control.
    Can anyone help me?
    Thx
    Stardusty

    Hi,
    That's the whole point. I don't want to use x:TypeArguments on a ResourceDictionary but the compiler says it needs it.
    And i don't know why.
    This code give no error:
    <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespaceystem;assembly=mscorlib">  
    </ResourceDictionary>
    And by adding 3 namespaces it gives that weard error:
    <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:MyTime.View.Controls"
    xmlns:converters="clr-namespace:MyTime.View.Converters"
    xmlns:validationrules="clr-namespace:MyTime.View.ValidationRules"
    xmlns:sys="clr-namespaceystem;assembly=mscorlib">  
    </ResourceDictionary>

  • Trouble changing a class attribute in a STATEFULL bsp app - PLEASE HELP!!!!

    hello, i have some trouble changing the value of a class attribute, in certain point of the execution of a statefull bsp app. The scenario is: the bsp app is on a url iview in a portal; i have some link in the portal, that do a window.open (pop up) of that app. the question is: how can i change the class attribute of the bsp app when i close that pop up?, if when i first click the link that show me the pop up, its doesn't create another instance of the class...i mean it continuing working with the same instance of the url iview in the portal. ANY help it will well received. Thanx in advance

    hello Durairaj...yes indeed in the other thread thats the issue with the portal_version attribute, the person who create the iview dont want to change it...so i try to solve it with something else....thats bring me to another problem (posted in this thread). Now i have a question...in the url iview it calls a template that start the bsp app...i mean is not the url iview who calls the bsp app is a middle template...with this scenario can i pass the parameter sap-sessioncmd=open to the url iview or i have to pass it to the bsp app directly when in the middle template i call it??? another question when i pass that parameter via url, it create another instances (apart) of the class or restart the same instance that the app work with until that moment....tell me more about that parameter coz' i am new in bsp and i need help....i will give a lots of rewards point who help me!!! i promise....i am kind of desperade for sure....  thanx in advance

  • Class attribute in technical workflow log not updated

    Hi Gurus,
    I built a workflow analogous to the famous demo workflow "demoformabs" but with the demo class: CL_SWF_FORMABSENC instead of the BOR: FORMABSENC.
    In the BOR Formabsenc there is also an attribute for the "Approver" (USR01) in addition to "Creator" (USR01).
    This attribute "Approver" is missing in the class "CL_SWF_FORMABSENC".
    So I added this attribute "Approver" also in the class "CL_SWF_FORMABSENC":
    data APPROVER type SIBFLPORB value CL_SWF_BOR_TYPES=>MC_USR01.
    Finally in the method "approve" I set the value for the attribute "APPROVER".
    me->approver-instid = me->APPROVBY.
    I can see that the value has been successfully set by setting a binding from this class attribute to a workflow container element.
    BUT, in the technical workflow log (container) I can not see the class attribute "Approver" populated.
    Here it´s still displayed as < no instance >.
    What do I need to do, to make this value appear also in this class attribute in the technical workflow log?
    Albeit I know, that it´s working, I am getting confused, that it´s still displayed as empty.
    Cheers,
    Dominik

    Hi Dominik,
    You should not populate attributes in this manner, for the very reason you're experiencing. Attributes are transient and behave like variables, i.e. when the class stops existing they disappear. During binding only the key is transferred, and - if needed - the class is re-instantiated at the other end. If you have implemented some kind of buffering/instance management (not a bad idea), then you may be lucky to have attributes survive if everything happens within the same program context. However once your WF session stops executing, this is lost.
    This is why when you look at the log later, it is re-instantiating a completely new instance - where would it know the approver from?
    The attribute value must be written to the DB somewhere, so that any later object instantiation (e.g. when you look at the log) will read the value and populate the attributes correctly.
    Incidentally this is why OO theory discourages the use of public attributes and suggests GET_ and SET_ methods instead....
    Regards,
    Mike

  • Model Binding and Calculated Field Syntax for "class" Attribute

    Hi,
    I tried to use the calculated field syntax from SAP UI5 to change the CSS class attribute of an element based on some model property, i.e., I wanted to change the class in the corresponding formatter function based on the currently bound value. However, my formatter function is not called. When I use the same syntax on a text attribute, it works.
    I also tried to use normal property binding, but it did not work on the class attribute either (it just put class="{property}" in the rendered HTML).
    Is there anything I missed or is it just not possible to use property binding and calculated field syntax for class attributes? Did anybody try something like this before?
    I think it is a standard use case to change the CSS class based on some model property. So, if anybody knows how to do that, could you give a short example?
    Best regards
    Svenja

    They have a class property. At least, I can do the following in an XML view:
    <Button
                  icon="sap-icon://add"
                  press="onButtonPress"
                  class="my-button-class" />
    I would expect the following to work as well, but for me it did not:
    <Button
                  icon="sap-icon://add"
                  press="onButtonPress"
                  class="{/customClass}" />
    This renders the following HTML (cropped to the important parts):
    <button type="button" class="sapMBtn {/customClass}">
    </button>
    It seems like the class attribute is something special although I don't see a reason why. Other HTML templating engines, for example, support things like that.

  • Field symbols as Class Attributes

    Hello Gurus,
    Is anybody able to say to me if it is possible to declare field symbols as class attributes? As I can understand until now, this is not possible and we need to use some attribute with the "TYPE REF TO Data" to get the information we need. Correct?
    Thanks,
    Daniel.

    Ok, let me see if someone can give me some idea on how to improve my method:
    Method: PREPARE_PTOOL_DATA
    Parameters specification:
    Parameter        Type     Typing     Reference Type
    PF_ANALYSIS        Importing     Type     /SYM/SC_PT_ID_ANALYSIS_D
    PF_ANAL_DESC        Importing     Type     /SYM/SC_NM_DESC_ANALYSIS
    PF_LOGIC        Importing     Type     CHAR01
    PF_MATERIAL        Importing     Type     MATNR
    PF_MAKTX        Importing     Type     MAKTX
    PT_DATA_COMPA        Exporting     Type     /SYM/SC_TAB_PT_RESULT_CP
    PT_CALC_ANALY        Exporting     Type     /SYM/SC_TAB_PT_RESULT_CA
    PT_DATA_MATERIAL1 Changing     Type     /SYM/SC_TAB_PROC_ALLERG_RESULT
    PT_DATA_MATERIAL2     Changing     Type     /SYM/SC_TAB_PROC_ALLERG_RESULT
    Source code:
    From the /SYM/SC_CL_PROCESS_ALLERG_GEN class
    Old version (but it is working)
    METHOD prepare_ptool_data.
      DATA: ls_data_material1   TYPE /sym/sc_s_proc_allerg_result,
            ls_data_material2   TYPE /sym/sc_s_proc_allerg_result,
            lf_index_material1  TYPE sy-tabix,
            lf_index_material2  TYPE sy-tabix,
            ls_result_cp        TYPE /sym/sc_pt_result_cp,
            ls_result_ca        TYPE /sym/sc_pt_result_ca.
    Prepare data for Data Comparison step
      IF pt_data_compa IS REQUESTED.
        LOOP AT pt_data_material1 INTO ls_data_material1.
          lf_index_material1 = sy-tabix.
          CLEAR ls_result_cp.
          MOVE pf_analysis   TO ls_result_cp-analysis.
          MOVE pf_anal_desc  TO ls_result_cp-desc_analysis.
          MOVE ls_data_material1-algbe TO ls_result_cp-desc_property.
    If Logic 'A', move the text from ls_data_material1 to original
    material status
          IF pf_logic EQ c_logic_a.
            MOVE ls_data_material1-agsbe TO ls_result_cp-val_orig_matnr.
    If Logic 'B', move the text from ls_data_material1 to "toy"
    material status
          ELSEIF pf_logic EQ c_logic_b.
            MOVE ls_data_material1-agsbe TO ls_result_cp-val_toy_matnr.
          ENDIF.  " IF pf_logic EQ c_logic_a.
    Read the lt_data_toy by the Allergen ID (ALGEN)
          CLEAR ls_data_material2.
          READ TABLE pt_data_material2 INTO ls_data_material2
                WITH KEY algen = ls_data_material1-algen BINARY SEARCH.
          IF sy-subrc EQ 0.
            lf_index_material2 = sy-tabix.
    If Logic 'A', move the text from ls_data_material2 to "toy°
    material status
            IF pf_logic EQ c_logic_a.
              MOVE ls_data_material2-agsbe TO ls_result_cp-val_toy_matnr.
    If Logic 'B', move the text from ls_data_material2 to original
    material status
            ELSEIF pf_logic EQ c_logic_b.
              MOVE ls_data_material2-agsbe TO ls_result_cp-val_orig_matnr.
            ENDIF.  " IF pf_logic EQ c_a.
    Delete record from lt_data_toy, index lf_index_toy
            DELETE pt_data_material2 INDEX lf_index_material2.
          ENDIF.  " IF sy-subrc EQ 0.
          APPEND ls_result_cp TO pt_data_compa.
    Delete record from lt_data_orig, index lf_index_orig
          DELETE pt_data_material1 INDEX lf_index_material1.
        ENDLOOP.  " LOOP AT lt_data_material1 INTO ls_data_material1.
      ENDIF.  " IF pt_data_compa IS REQUESTED.
    Prepare data for Calculation Analysis step
      IF pt_calc_analy IS REQUESTED.
        LOOP AT pt_data_material1 INTO ls_data_material1.
          lf_index_material1 = sy-tabix.
          CLEAR ls_result_ca.
          MOVE pf_material   TO ls_result_ca-matnr.
          MOVE pf_maktx      TO ls_result_ca-maktx.
          MOVE pf_analysis   TO ls_result_ca-analysis.
          MOVE pf_anal_desc  TO ls_result_ca-desc_analysis.
          MOVE ls_data_material1-algbe TO ls_result_ca-desc_property.
    If Logic 'A', move the text from ls_data_material1 to original
    material status
          IF pf_logic EQ c_logic_a.
            MOVE ls_data_material1-agsbe TO ls_result_ca-val_curr_stat.
    If Logic 'B', move the text from ls_data_material1 to "toy"
    material status
          ELSEIF pf_logic EQ c_logic_b.
            MOVE ls_data_material1-agsbe TO ls_result_ca-val_simul_stat.
          ENDIF.  " IF pf_logic EQ c_logic_a.
    Read the lt_data_toy by the Allergen ID (ALGEN)
          CLEAR ls_data_material2.
          READ TABLE pt_data_material2 INTO ls_data_material2
                WITH KEY algen = ls_data_material1-algen BINARY SEARCH.
          IF sy-subrc EQ 0.
            lf_index_material2 = sy-tabix.
    If Logic 'A', move the text from ls_data_material2 to "toy°
    material status
            IF pf_logic EQ c_logic_a.
              MOVE ls_data_material2-agsbe TO ls_result_ca-val_simul_stat.
    If Logic 'B', move the text from ls_data_material2 to original
    material status
            ELSEIF pf_logic EQ c_logic_b.
              MOVE ls_data_material2-agsbe TO ls_result_ca-val_curr_stat.
            ENDIF.  " IF pf_logic EQ c_a.
    Delete record from lt_data_toy, index lf_index_toy
            DELETE pt_data_material2 INDEX lf_index_material2.
          ENDIF.  " IF sy-subrc EQ 0.
          APPEND ls_result_ca TO pt_calc_analy.
    Delete record from lt_data_orig, index lf_index_orig
          DELETE pt_data_material1 INDEX lf_index_material1.
        ENDLOOP.  " LOOP AT lt_data_material1 INTO ls_data_material1.
      ENDIF.  " IF pt_calc_analy IS REQUESTED.
    ENDMETHOD.
    As you can see, I am repeating almost the same code, just changing some items. I am not sure if I can use new parameters (ANY or ANY TABLE) but, my first idea to improve it was to use the field-symbols (and it works ok). The issue is that I have to repeat the assignment lines every same named method of the classes I am changing (I would like to do the assignment into a new method of the superclass). Do you think it is possible or should I give up and proceed with the assignments locally, for each same named method of each class?
    Thanks,
    Daniel.

  • Robohelp 8 & CSS Class attribute

    I have been trying to use the CSS Class attributes but it doesn't seemed to be recognized by Robohelp 8. Here is an example of my code:
    My external style sheet:
    Test {
              width: 562px;
              height: 16px;
              text-align: center;
              font-family: Arial, Helvetica, sans-serif;
              font-weight: bold;
              color: #ffff00;
    Test1 {
              background-color: #00900;
    Test2 {
              background-color: #008000;
    In my file:
    <link rel="Stylesheet" href="layout.css" type="text/css" />
    <div class="Test Test1">
         I type something here
    </div>
    The text that I type is rendered but none of the formatting.  What am I doing wrong?
    Does anyone know if there is a problem with Robohelp 8 not supporting CSS classes?
    Thanks!
    Message was edited by: Lakooli

    Hi,
    Add a dot (.) before the class definitions in your css:
    .Test -> All elements that have the class test
    Or even better:
    div.Test -> Only DIV element that have the class test
    Greet,
    Willam

  • JavaBeans class attribute problem

    Hi,
    I am using JavaBeans in my JSP application to represent the business logic. I am just writing a simple JavaBean to calculate wages. The bean(which is called PayBean) compiles fine and the class resides in the folder \web-inf\classes\com\mybean\pay\
    In the JSP page I have
    <jsp:useBean id="payBean" class="com.mybean.pay.PayBean"/>to call my bean.
    However, when I ran the JSP I get the following error:
    The value for the useBean class attribute com.mybean.pay.PayBean is invalid.
    I tried restarting tomcat, but to no avail. Does anyone know what is wrong with my code?
    I have written and used bean using the same procedure and it ran fine, so I am really puzzled.
    Thanks

    Your bean payBean must have a public constructor that takes no arguments. (or no constructor at all, in which case it automatically gets one)
    ie
    package com.mybean.pay.PayBean
    public class PayBean{
      public PayBean(){ 
    }Cheers,
    evnafets

Maybe you are looking for

  • How can I match tempo & sync of old audio files to Garageband?

    HI all, Final question and it's a doozy. While I know the "general concepts" for trying to accomplish the following, acutally trying to get it to work is frustrating. At first thought that the new Garageband tempo/playing thing would work but I'm not

  • How to print report from JSP Page

    Hi Everybody, I am developing a simple project in JSP with MS Access. I hav some tables and reports for them. I hav a JSP page which gets inputs from user and save it in the table. Its working fine. But my problems are, 1) I hav a button called "SAVE

  • I want to know when the Firefox 27.0 that's not beta version will releases on Windows.

    I know the Firefix beta has been released for Windows on last week. So in the futere, the Firefox beta version will be just Firefox. Do you understand about my saying? I'm sorry for my poor skill making grammer. But I would like to know the date that

  • Using e-mail reminders with Gmail

    My e-mail account are all Gmail, and apparently this causes my e-mail reminders to go into my gMail web mail but not get forwarded to my Mail.app because they were sent by "Me." Is there a workaround this in iCal, Mail or Gmail?

  • Changes in SAPBW system to connect Business object system

    hi,    Do we need change any settings in SAPBW  System  in order to connect Business Objects system for example: do we add any transports... Thanks