Forum Stats

  • 3,827,925 Users
  • 2,260,839 Discussions
  • 7,897,407 Comments

Discussions

How to enable for user to set null value to required field

Robert Šajina
Robert Šajina Member Posts: 94
edited Oct 30, 2017 8:35AM in JDeveloper and ADF

Hi all,

In our application we have a requirement that when a user clears input field a null value should be set on that field in view object.

Also component on jsf has required property set to true.

When the user clear the old value he gets the warning of required field but no value has been sent to view object, and in our case we need to send a null value to view object.

We have multiple cases in our application with this requirement so we are looking for a solution( if possible not to complex)

Thank you,

Robert 

JDeveloper: 12.2.1.2.0.0.

Tagged:
Cvele_new_accountkumar santosh
«1

Answers

  • managed BEAN
    managed BEAN Member Posts: 948 Silver Badge
    edited Oct 24, 2017 10:09AM

    Hi,

    So why don´t you set the property 'required=false' ?

    That is not a complex solution .

    Regards,

    Carlos

    Cvele_new_accountkumar santosh
  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,462 Red Diamond
    edited Oct 24, 2017 11:13AM

    To implement this you have to do the validation yourself. The required validation will not allow you to clear the filed. So you can use the showRequired property on the inputfield and when submitting the data (or on valueChange) check if the field is empty and show the warning.

    Timo

  • Cvele_new_account
    Cvele_new_account Member Posts: 4,810 Bronze Crown
    edited Oct 24, 2017 11:53AM

    Go to the Bindings section of the page (page Definition), locate related iterator, and set ChangeEventPolicy property to be none

    kumar santosh
  • Robert Šajina
    Robert Šajina Member Posts: 94
    edited Oct 25, 2017 4:03AM

    Hi all,

    thank you for your responses.

    We could easily set property required to false but we want to be consisten in the whole application.

    Iterator change policy is already set to none.

    Timo, i will try your suggestion, doesen't seems to complicated:

    Robert

  • managed BEAN
    managed BEAN Member Posts: 948 Silver Badge
    edited Oct 25, 2017 4:15AM

    Hello,

    But you want to show a message to user saying the field is empty, although he cleared it and in spite it is required(or marked as required) ,and still proceed with the execution and set null?

    Regards,

    Carlos

  • Robert Šajina
    Robert Šajina Member Posts: 94
    edited Oct 25, 2017 2:14PM

    Hi managed BEAN,

    we want to keep the default required message and default validation ( field is required) but we also need to set the value to null because of other logic in rowImpl class.

    Robert

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,462 Red Diamond
    edited Oct 25, 2017 2:38PM

    Sorry, but this doesn't make sense.

    Required means that there must be a value. If you let the user set it to null it's not required.

    Timo

  • Robert Šajina
    Robert Šajina Member Posts: 94
    edited Oct 27, 2017 2:03AM

    Hi Timo,

    i know that it doesn't make much sense, but that's the requirement that we need to implement.

    We need it because:

    In our rowImpl class we are suggesting a value to other field when a user select a value from LOV, so when the user clears that suggested value from that input field, we need to set it to null in rowImpl class so that if the user select another value from LOV that value is suggested again. If that value is not null than we are not suggesting anything.

    So the only way for that value (which is required) to be null is to somehow send null value to rowImpl

    Robert

  • Amaan Junaid
    Amaan Junaid Member Posts: 262
    edited Oct 27, 2017 2:45AM

    Hi,

    In this case you can use show required property on your field to show that the field is required. This will maintain the consistency.

    Second in the Entity or ViewObject set the field as non mandatory.

    When the user finally saves the record, at that time you can validate manually if the field is null or not. When it is null then you can show the message to the field by using facesMessage and attaching the message to the field.

    Thanks

    AJ

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,462 Red Diamond
    edited Oct 27, 2017 4:12AM
    So the only way for that value (which is required) to be null is to somehow send null value to rowImpl

    When you save the row the field must have a value, otherwise, it's not required or mandatory.

    It'S you use case, the only way I see to implement this is the showRequired attribute in the ui I already mentioned.

    Timo

This discussion has been closed.