Mike Kienenberger wrote:
What is it that you cannot do with subforms?   You mention making
required optional elsewhere -- required="#{bean.isrequirednecessary}"
should take care of that..

If you have a specific example, I'm sure you can get help here to find
a solution using subForms.

Here's a the view i'm working on. The input parameters in the form are
generated dynamically. Each input field has a separate required value
which needs to be maintained. During the "update form values to model"
operation the required attribute should be false for all inputs, but
in other cases the value should be the component's actual required
attribute value. All non-empty form field values that get succesfully
converted should be updated to the model even if there are required
values missing. It should be possible to use value binding for getting
the required attribute value, as you suggested. Since the inputs are
dynamically generated the value bindings would end up looking
something like this:

required="#{bean.isrequirednecessaryMap['fieldid']}"

Another approach that comes to mind is using a custom validator for
requiring a field to have a value instead of the required attribute.
When validation is to be skipped for a request, the validator returns
normally for all components, if validation needs to be done it throws
ValidatorException for empty fields. I've been trying out this
approach a bit but for some reason JSF doesn't seem to care about the
ValidatorExceptions that get thrown. It might be that my custom
components don't properly propagate isValid status up the component
tree.


Here's the form:

<html>
<trh:body onload="checkAndOpenPopup();">

<h:form>
<h:inputText required="true"/>
<h:commandLink 
actionListener="#{reportSelectionHandler.startSelectParameterValues}">
<h:graphicImage url="foo.gif"/>
<t:updateActionListener
property="#{reportSelection.reportParameterName}"" value="foo"/>
</h:commandLink>

<h:inputText required="false"/>
<h:commandLink 
actionListener="#{reportSelectionHandler.startSelectParameterValues}">
<h:graphicImage url="foo.gif"/>
<t:updateActionListener
property="#{reportSelection.reportParameterName}"" value="bar"/>
</h:commandLink>

<h:commandButton value="get report"
actionListener="#{reportSelectionHandler.fetchReport}"/>
</h:form>

<h:form id="parameterSelectOpener" target="parameterSelect">
 <h:inputHidden value="dummy"/>
 <h:commandButton id="parameterSelectOpenerSubmit" type="submit"
styleClass="hidden-object"
           action="#{reportSelectionHandler.updateSelections}"/>
</h:form>

</trh:body>

<script type="text/javascript">
function checkAndOpenPopup() {
 // if startSelectParameterValues actionListener was succesfully
executed, submit parameterSelectOpener to open a popup window.
 // if fetchReport actionListener was succesfully executed, submit a
form which would open up the form in a popup window
}
</script>

</html>

Reply via email to