1
votes

I'm working on upgrading an application from Icefaces 1.8 to IceFaces 3.3

Running on WAS 8.5, IceFaces 3.3 (JSF 2.1 - MyFaces 2.1.17)

I have a pop-up box that is used to create new users.

<f:facet name="body">
    <ice:panelGrid columns="3">
        <ice:outputText value="User Id"></ice:outputText>
        <ice:inputText id="CreateNewUserPopUp-UserId" binding="#{menuBean.userPanel.userN}" action="#{menuBean.userPanel.checkUserId}"
            disabled="#{menuBean.userPanel.validUserId and !menuBean.userPanel.userIdExists}" maxlength="30" value="#{menuBean.userPanel.userN}">
        </ice:inputText>
        <ice:message for="CreateNewUserPopUp-UserId" id="CreateNewUserPopUp-UserIdMessage" style="color: Red; font-style: italic; font-size: 12px;"/>

        <ice:outputText value="User Name"></ice:outputText>
        <ice:inputText id="CreateNewUserPopUp-UserName"  binding="#{menuBean.userPanel.userNameT}" 
            disabled="#{!menuBean.userPanel.validUserId or (menuBean.userPanel.validUserId and menuBean.userPanel.userIdExists)}"
            style="width:300px" maxlength="30">
        </ice:inputText>
        <ice:message for="CreateNewUserPopUp-UserName" id="CreateNewUserPopUp-UserNameMessage" style="color: Red; font-style: italic; font-size: 12px;"/>
        ...
        ...
    </ice:panelGrid>
</f:facet>

It's bound to HtmlInputText components for the userN and userNameT:

private HtmlInputText userN;
private HtmlInputText userNameT

When the pop up box is rendered, all fields are initialised and focus is requested for the user Id input box

public void clearNewUser()
{
    setValidUserId(false);
    setUserIdExists(false);
    getUserN().setValue("");
    getUserNameT().resetValue();
    ...
    ...
    getUserN().requestFocus();
}

If I press ENTER when on the userN box, then the validation code is executed.

public void checkUserId()
{
    ...
    ...
    if (getUserN().getValue().toString().trim().length() < 1)
    {
        setMessage("User Id required");
    }
    else
    {
        DtcUsersTable dtcUsersTable = usersTableService.findById(getUserN().getValue().toString().toLowerCase());

        if (dtcUsersTable != null)
        {
            setValidUserId(true);
            setUserIdExists(true);
            setMessage("User Already Exists");
        }
        else
        {
            setValidUserId(true);
            setUserIdExists(false);
            getUserNameT().requestFocus();
            setMessage("Please Enter User Details");
        }
    }
}

If the input box is empty, my warning message to the user is correctly displayed stating "User Id required".

If I populate the box and press ENTER, all my processing is completed correctly, the input box is validated and disabled so the user ID can't be edited post-validation and the User Name input box is selected as the new focus. Then a message is displayed in the console log stating:

000001a1 BeanValidator W   cannot validate component with empty value: APP:CreateNewUserPopUp-UserId

If I leave the User Name box empty and tab through the other required information boxes, then there are no console messages displayed, but if I populate the User Name input box then every time I switch input box I get the console message:

0000019d BeanValidator W   cannot validate component with empty value: APP:CreateNewUserPopUp-UserName

I have tried searching online and have been unable to find someone else having the same issue. The only thing I can think of is to change the log levels to prevent bean validator warnings being shown, but that's just brushing the issue under the rug not fixing it.

Does anybody have a clue what I can do to fix this?

1

1 Answers

1
votes

I found the answer. It's complaining about the value attribute in the xhtml.

I've changed the userN and userNameT to be String and moved them into the value property. I've also added in 2 newly named components to the binding property.

<f:facet name="body">
    <ice:panelGrid columns="3">
        <ice:outputText value="User Id"></ice:outputText>
        <ice:inputText id="CreateNewUserPopUp-UserId" binding="#{menuBean.userPanel.userInputN}" action="#{menuBean.userPanel.checkUserId}"
            disabled="#{menuBean.userPanel.validUserId and !menuBean.userPanel.userIdExists}" maxlength="30"
            value="#{menuBean.userPanel.userN}">
        </ice:inputText>
        <ice:message for="CreateNewUserPopUp-UserId" id="CreateNewUserPopUp-UserIdMessage" style="color: Red; font-style: italic; font-size: 12px;"/>

        <ice:outputText value="User Name"></ice:outputText>
        <ice:inputText id="CreateNewUserPopUp-UserName"  binding="#{menuBean.userPanel.userNameInputT}" 
            disabled="#{!menuBean.userPanel.validUserId or (menuBean.userPanel.validUserId and menuBean.userPanel.userIdExists)}"
            style="width:300px" maxlength="30"
            value="#{menuBean.userPanel.userNameT}">
        </ice:inputText>
        <ice:message for="CreateNewUserPopUp-UserName" id="CreateNewUserPopUp-UserNameMessage" style="color: Red; font-style: italic; font-size: 12px;"/>
        ...
        ...
    </ice:panelGrid>
</f:facet>

I've added 2 new HtmlInputText components into the Java class

private HtmlInputText userNameInputT;
private HtmlInputText updateUserNameInputT;

private String userN;
private String userNameT;

Updated the method that initialises the fields

public void clearNewUser()
{
    setValidUserId(false);
    setUserIdExists(false);
    setUserN("");
    setUserNameT("");
    ...
    ...
    getUserInputN().requestFocus();
}

Updated the validation code for the request focus and changed any code that used to use .getValue().toString() on the input fields. As they are now Strings, this isn't needed.

public void checkUserId()
{
    ...
    ...
    if (getUserN().trim().length() < 1)
    {
        setMessage("User Id required");
    }
    else
    {
        ...
        ...
        else
        {
            setValidUserId(true);
            setUserIdExists(false);
            getUserNameInputT().requestFocus();
            setMessage("Please Enter User Details");
        }
    }
}

It's all working fine now