I have a question according to <h:message for="" />
JSF object. I have a JSF 1.1 (yes, unfortunatelly) myFaces project. I've prepared a simple JSP file with label, inputText and message holder:
<h:form id="sacLinkForm">
<cblFaces:outputLabel for="dedicatedCashAccountNumber"
value="#{appBundle.KUSTA_DEDICATED_CASH_ACCOUNT_NUMBER}"/>
<t:inputText id="dedicatedCashAccountNumber"
value="#{createController.modelFE.sacLink.dedicatedCashAccountNumber}"/>
<h:message id="dedicatedCashAccountNumberError"
for="dedicatedCashAccountNumber" />
</h:form>
Also I've created simple validation method:
public static boolean validate(SACLink link) {
boolean isError = false;
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage();
message.setSeverity(FacesMessage.SEVERITY_ERROR);
if (StringUtils.isEmpty(link.dedicatedCashAccountNumber)) {
//MessageUtils.addErrorMessage("dedicatedCashAccountNumber", "Dedicated Cash Account Number is mandatory");
message.setSummary("Field mandatory");
message.setDetail("Dedicated Cash Account Number is mandatory");
context.addMessage("sacLinkForm:dedicatedCashAccountNumber", message);
isError = true;
}
return !isError;
}
My problem is with sacLinkForm:dedicatedCashAccountNumber
because compiled JSP has generated id (f.e. _idJsp12:DynTab2:DynView2:tabK.....er:vKustaMa....Controller:sacLinkForm:dedicatedCashAccountNumber
) and it probably causes that addMessage
method doesn't correspond with h:message for=".."
attribute.
So the message is not displayed correctly because java could not find correct h:message
object. Is there any way how to set message to the correct h:message
from Java? I assume that there is no way how to force 'constant' component ID in the JSF 1.1 pages.
Thank you.