Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Foreign key form items with titles set not set properly?

    Please consider the following .ds example:
    Code:
    <field name="contractorId" type="integer" foreignKey="contractor.id" displayField="name" required="false">
        <title> <fmt:message key="contractorId"/> </title>
    </field>
    As you can see, this is a foreign key field that points to another datasource.

    From what i can see, The fmt:message title i have set is not used for a foreign key field declaration. Instead, it uses the title in my foreign key datasource and if that is not set, it just uses the capitalized datasource name.

    To me, it makes more sense if the title i have specified in the field itself overrides any default behavior? I'm not sure when exactly this was changed, but i think it works like this in 12.

    Cheers

    #2
    Nothing has changed. What is more likely is that during the upgrade process, files were moved around your current locale file lacks this particular key.

    Comment


      #3
      well, that's of course what i tried first.

      However, if i take that property key, "contractorId" and apply it to any other field in the datasource file, it works. Conversely, it doesn't matter which property i set for the foreign key field, it is not applied. The only thing that worked for me was adding a title to the foreign key datasource.

      Comment


        #4
        Hi mathias,

        can you check your DataSourceLoader-Call result? That way you can see if the server side might be causing your issue (wrong or no title) or the client side is (correct key in response, nevertheless wrong string displayed).

        Best regards
        Blama

        Comment


          #5
          You have a displayField set. If that displayField is for an includeFrom field, then that’s the title that will be used, because it’s the title from the field whose value is being displayed.

          Perhaps that is what makes you think the title is coming from the other DataSource - because that’s a general rule for displayFields.

          Comment


            #6
            Blama , whatever happens is on the serverside, among the first things i checked. If i look at the datasourceloader response, the strange title is already applied, i.e. value is not lifted from the property file on the server
            name:"contractorId",displayField:"name",type:"integer",title:"Subcontractor",foreignKey:"contractor.id",required:false}
            Isomorphic yes i have a displayfield set, but i must confess i don't understand how that relates.
            The displayfield is how i specify which field in the related datasource to use as values in the dropdown, not the title of the form field itself?

            I also have to say that i'm basically 100% sure that it is indeed coming from the other datasource .ds file. I just now go in to the actual contractor.ds.xml file in the deployed war and add or remove the
            Code:
            <title><fmt:message key="ds_contractor"/></title>
            row in the datasource file, and then just reload the web page, the title for the form field changes back and forth right away.

            Comment


              #7
              As far as displayField and titles from the related DS, in this case, the value being saved is a "contractorId", however the end user doesn't know this, and because of the displayField setting, the user is seeing contractor names, and so that is the field that supplies the title. This is expected and as-designed.

              Separately, you seem to be saying that the <fmt> tag isn't resolving for the contractorId attribute. This is odd, even if it wouldn't be used by default.

              However, the subsystem that does this <fmt> resolution doesn't know anything about foreignKeys or displayFields - it treats all tags the same.

              So we would look for the cause elsewhere - one important thing is to check whether any other <fmt> tags resolve in this DataSource. If they don't, then you have a DataSource-wide problem, clearly.

              Comment


                #8
                EDIT. I have found the issue, it was my end. Long story short, i had custom code setting titles in some circumstances that didn't work so well with the "autoDeriveTitles" setting, that i had missed was a thing. Thanks for your time :)
                Last edited by mathias; 8 Nov 2022, 12:42.

                Comment

                Working...
                X