Skip to Content
author's profile photo Former Member
Former Member

Data binding doesn't work with dynamic indices

Hi all,

I have got a problem with data binding and can't think of a way to fix it. My code looks like the following:


Although the string for databinding looks good, it doesn't work! The string (e.g. //model/MT_MTRRA[1].readingresult) is simply shown as input in the input field.

When hard-coding the index:




data binding works, but a hard-coded index is of course not what I want. Using a table view instead is not an option, because the structure to be edited is too complex for that.

Any suggestions?



Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Oct 24, 2003 at 04:57 PM

    Hallo Stephan,

    It is always the simple questions that have the most complex answers.

    The reason for this "problem" is that you are using the model binding outside the scope of its design. For each attribute of a tag, there is usually a corresponding attribute on that class. So the code "<htmlb:inputfield id=abc>" will result that somewhere in the generated code there will be a statement "obj_inputfield->id = 'abc'.".

    However, for all attributes that are defined as model binding capable, there are **two** attributes. The one attribute is the actual value (which does NOT have to be of type STRING), and the second attribute for the model string (which MUST be of type STRING). This second attribute will always have the name _value.

    So now, during the compiler run, correct coding must be generated to fill either value or _value. And this is the reason why dynamic expressions (strings that are only known at runtime), can not be used for model binding. Already at compile time we require these values. (OK, you can argue that this first part of the string is already constant, but this compiler sees the complete string as expression and can not work with it.)

    I will offer you here a workaround. This is coding that we do officially support, and is the technique how you can dynamically program tags. (I am actually writing a weblog about this at the moment.) I give you the answer, and think that the some code will speak for itself :). For the rest, I would appreciate it if you could wait for my next weblog.


    <htmlb:inputField id="READINGRESULT<%= l_cstr %>"

    value="//model/MT_MTRRA[<%= l_cstr %>].readingresult" />



    data: inputfield TYPE REF TO CL_HTMLB_INPUTFIELD.


    id_postfix = l_cstr

    disabled = 'TRUE' ).

    CONCATENATE '//model/MT_MTRRA[' l_cstr '].readingresult' INTO inputfield->_value.


    <bsp:bee bee = "<%=inputfield%>" />

    regards, brian

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.