0

I have to migrate richfaces 3.3.3 JSF 1.2 to Primefaces 7.0 JSF 2.1, so thats why a lot here is not ideal ... but thats how it is...

The main problem seems to be that my value attribute has to be a String and that I have to put at the start a value in and this value has to be converted to a label. As long no POJO's are involved I have to convert often and expensive, but it works, my toObject is the model/value String, my toString is the label and the completeMethod delivers a list of label Strings.

                <p:autoComplete id="berufstitel1Suggestion" value="#{partner.berufsTitel1Key}" maxlength="100" disabled="#{fieldsDisabled}" queryDelay="500" 
                    completeMethod="#{autoSuggestion75.getListForPFAutocomplete}" emptyMessage="Keine Treffer" dropdown="true" readonly="#{fieldsDisabled}" minQueryLength="2"
                    converter="supportjsf.autocomplete.schluessel" forceSelection="true" scrollHeight="150" cache="true" >
                    <f:attribute name="#{jsfUtilConstants.PARAM_SCHLARTCD}" value="#{regeldatenKonstantenPartnerS075.SCHLUESSEL_CD_BERUF_TITEL}" />
                    <f:attribute name="#{jsfUtilConstants.PARAM_SUPPORTDATA}" value="#{supportData75}" />
                    <f:attribute name="#{jsfUtilConstants.PARAM_KURZBEZ}" value="#{true}" />
                </p:autoComplete>

What also works: if label and value are the same und I want to beautify the label in the autocompletebox but show the normal label when choosen (beautify only for additional infos when choosing):

            <p:autoComplete id="ikzsuggestion" value="#{ptnAdr.adresse.staat}" maxlength="10" size="4" disabled="#{fieldsDisabled}" completeMethod="#{autoSuggBean[ikzSuggMethod]}"
                    emptyMessage="Keine Treffer" dropdown="false" readonly="#{fieldsDisabled}" minQueryLength="2" forceSelection="true" scrollHeight="200" var="ikz" itemValue="#{ikz}"
                    itemLabel="#{ikz}" queryDelay="500">
                    <f:attribute name="#{jsfUtilConstants.PARAM_SUPPORTDATA}" value="#{supportData75}" />
                    <p:column>
                        <h:outputText value="#{ikz}" />
                    </p:column>
                    <p:column>
                        <h:outputText value="#{ikz}" converter="ukisjsf.staatikz2bezeichnungconverter">
                            <f:attribute name="#{jsfUtilConstants.PARAM_SUPPORTDATA}" value="#{supportData75}" />
                        </h:outputText>
                    </p:column>
                </p:autoComplete>

But what I do not get working is a combination of this two. The model/value and the label are different Strings and I want to beautify the labels in the autocomplete-box. To beautify anything I think I will need this "var" attribute like shown in my second example, but here things fall appart. No matter what I do, it does not work.

Anyone a solution to this?

Additional info: I tried a lot with POJO's but because the value attribute has to be a String and reload the whole widget after a commit has to work I did not get anything going with POJO's. Why it fails with POJO's is explained here: Primefaces autocomplete with POJO and String value

After days of trying I found this two solutions with Strings, but a combinations fails.

Ande Hofer
  • 150
  • 2
  • 14
  • 1
    Can you please summarize what you want to do. I have tried reading it a few times, but it is hard to follow. I am not expecting answers in its current form. – Jasper de Vries May 15 '21 at 07:56
  • Of course, sorry for the bad english. I need the attribute value to be a String, not a Pojo and I need it to be an another value than shown in the text-box (value/label) AND I need to alter the label in the autocomplete-box again to add some more info. As example: 123 is the value for the label AUT, but in the autocompletebox I need to show "AUT Austria". So I have 3 Strings, 1 for the database model (123), one to be shown (AUT) and one only for the autocomplete-box when the user choose (AUT - Austria). – Ande Hofer May 15 '21 at 08:13

0 Answers0