We have a UI for an entity that either has an instrument or an issuer, but never both. You can select one of each from a popup search dialog and assign it to the entity.
The user can see the number and name of each of the two next to the "Search..." button. Both of these must be non-editable, that is we the the respective <p:inputText ... readonly="true" ... />
to grey out the inputs.
The requirement we have now is that not only a validation message is supposed to be shown when either none or both of the instrument and issuer are selected, but also that the text boxes tagged with readonly="true"
are shown in red (along with their labels).
When adding, before pressing "Save":
When adding, after pressing "Save":
I tried a few things and then I ended up with OmniFaces <o:validateMultiple>
, which seemed to go into the right direction. However, I then noticed that the validator didn't kick in, as you can see from the images... (I just removed the readonly="true"
for you to see the effect)
Here's the code excerpt:
<!-- this panel is insider a form, yes -->
<h:panelGroup id="subpanel"
layout="block">
<o:validateMultiple id="instrument-or-issuer-validator"
validator="#{barrierCrossingManager.validateInstrumentOrIssuer}"
components="instrument-isin instrument-description issuer-number issuer-name"
message="..." />
<!-- some panel grid with the inputs -->
...
<p:panelGrid id="issuer-subpanel">
<p:row>
<p:column>
<p:outputLabel for="issuer-number" value="#{msg['common.number.label']}:" />
</p:column>
<p:column colspan="3">
<p:inputText id="issuer-number"
value="#{barrierCrossingManager.selectedIssuer.nbr}"
readonly="false" />
</p:column>
...
</p:row>
</p:panelGrid>
...
<h:messages id="msgs"
layout="list"
styleClass="subcontent-validation-msg-wrapper"
showDetail="false"
showSummary="true" />
</h:panelGroup>
Q:
How do you solve this?
The problem seems to be that OmniFaces or JSF(?) doesn't do validation of readonly components. I also looked at the OmniFaces VDL for <o:validateMultiple>
, but there wasn't a flag like allowReadOnlyComponentHighlighting
or similar.
Is there another way?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…