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

MVC Data binding problem

Hi @all,

I would like to develop a dynamic/generic BSP extension for an inputField. Now i have the following Problem. I have a view with a number of parameters. The model instance of the calling BSP is also passed as an attribute to my view. Now the view simply contains an InputField:

<htmlb:inputField id="<%=vh_id%>"

type="string"

visible="true"

disabled="false"

value="//model/client.clientno"

maxlength="<%=vh_width%>"

size="<%=vh_width%>" />

If I call it like this the InputField is filled with the value of //model/client.clientno. Now I would like to parametrize the value Attribute too:

<htmlb:inputField id="<%=vh_id%>"

type="string"

visible="true"

disabled="false"

value="<%=vh_value%>"

maxlength="<%=vh_width%>"

size="<%=vh_width%>" />

Now if I pass "//model/client.clientno" as vh_value in the call of my BSP-Extension:

<bsp:parameter name="vh_value" value="//model/client.clientno" />

it doesn't fill in the value but it simply writes "//model/client.clientno" (without the quotation marks) into the input field.

I know there is a workaround like this:

<bsp:parameter name="vh_value" value="<%=model->client-clientno%>" />

But with this the workaround if I change the value of my InputField in the browser the changed value is never returned to the model.

any ideas?

thx in advance,

Stefan

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 28, 2004 at 03:26 PM

    Hi Stefan,

    if data binding does not work I would have a look in the controller method do_handle_data and set a breakpoint to check the values of "form_fields".

    Here you can see how the form-fields are passed from the request and dispatched to the appropriate model-attrbs (fill_model_data( ) ).

    If this does not bring any solution you can even have a look at dispatch_input() of your (main-)controller to check the correct dispatching to your component (comp_id) and its values.

    Regards , Bernd

    Regards, Bernd

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 28, 2004 at 06:08 PM

    Stefan,

    The problem is actually complex.

    When the compiler sees a tag, it generates code to execute it.

    <u><b>The BSP compiler sees:</b></u>
    <tag:element a1 = "v1"/>
    <u><b>It generates code::</b></u>
    DATA: _t1 TYPE REF TO CL_TAG_ELEMENT.
    CREATE OBJECT _t1.
    _t1->a1 = 'v1'.
    ...code to execute tag...
    

    The problem is now what happens if the attribute is of type integer, or of type ref to data, and we have model binding. Then it is not possible to place the binding string inside the attribute (not matching types). So for this reason, once model binding is set for a specific attribute, there are configured two attributes. The one is of the configured type, the other (prefixed with _) is of type string for the binding path. Only one is set.

    <u><b>The BSP compiler sees:</b></u>
    <tag:element a1 = "//model/m1"/>
    <u><b>It generates code::</b></u>
    DATA: _t1 TYPE REF TO CL_TAG_ELEMENT.
    CREATE OBJECT _t1.
    _t1-><b>_</b>a1 = '//model/m1'.
    ...code to execute tag...
    

    So already from the beginning, the compiler must know whether it must set a1 or _a1. Model binding is pure compile time construct, and does not work at runtime. It is not possible to set this parameter dynamically.

    The only possible way to achieve this, if you really insist, is to dynamically process the tag directly on the page. Then you must set the attributes yourself correctly.

    For background reading information, I would recommend this new weblog:

    <b>BSP Programming: Writing Composite Elements</b>

    /people/brian.mckellar/blog/2004/07/28/bsp-programming-writing-composite-elements

    The expected code will be about (if you really insist):

    <%
        DATA: myTag TYPE REF TO CL_TAG_ELEMENT.
        myTag = CL_TAG_ELEMENT=>FACTORY( _a1 = vh_value ).
        WHILE _m_page_context->element_process( myTag )
                 = if_bsp_element=>co_element_continue.
        ENDWHILE.
    %>
    

    ++bcm

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 13, 2004 at 03:26 PM

    Hi Stefan,

    How to create dynamic input field in MVC method?pls..help me..

    Thnx .sun

    Message was edited by: Sun

    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.