Apache Trinidad tr:panelTabbed always validates content of current tab

StackOverflow https://stackoverflow.com/questions/7118156

  •  02-01-2021
  •  | 
  •  

سؤال

I have a Problem with the Apache Trinidad tr:panelTabbed component. I am trying to put different forms into the tabs (tr:showDetailItem) of this component. This, for the first try, does not work at all (I get a at NullPointerException, org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.FormValueRenderer.addNeededValue(FormValueRenderer.java:126):

<tr:panelTabbed>
  <tr:showDetailItem text="First tab">
    <tr:form>
      <tr:inputText label="Value 1" value="#{myBean.someValue1}" required="true" />
      <tr:commandButton text="Save Value 1" actionListener="#{myBean.saveValue1}" />
    </tr:form>
  </tr:showDetailItem>
  <tr:showDetailItem text="Second tab">
    <tr:form>
      <tr:inputText label="Value 2" value="#{myBean.someValue2}" required="true" />
      <tr:commandButton text="Save Value 2" actionListener="#{myBean.saveValue2}" />
   </tr:form>
  </tr:showDetailItem>
</tr:panelTabbed>

As this error also happens when I have no content inside my tr:form tags, so it has nothing to do with my own Java beans.

I found out that the tr:panelTabbed must be placed inside a tr:form tag. As one form tag in an other form tag is not allowed (that leads again to the exception mentioned above), i changed my code to this:

<tr:form>
  <tr:panelTabbed>
    <tr:showDetailItem text="First tab">
      <tr:inputText label="Value 1" value="#{myBean.someValue1}" required="true" />
      <tr:commandButton text="Save Value 1" actionListener="#{myBean.saveValue1}" />
    </tr:showDetailItem>
    <tr:showDetailItem text="Second tab">
      <tr:inputText label="Value 2" value="#{myBean.someValue2}" required="true" />
      <tr:commandButton text="Save Value 2" actionListener="#{myBean.saveValue2}" />
   </tr:showDetailItem>
  </tr:panelTabbed>
</tr:form>

That works fine in the first place, but leads my to my final problem:

I have some validation in each form. When the user tries to switch to the second tab while the first one contains validation errors, he or she is not allowed to do so. I want to avoid this behavior, but I also want to validate the content of the current tab when the user clicks on the save button.

Any suggestions how to solve this?

Thanks in advance

هل كانت مفيدة؟

المحلول

Trinidad has a tr:subform tag that might do just what you need, try using one general tr:form tag and a small tr:subform inside each panel (I hope you want to validate the forms separately).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top