0
votes

JSF 2 problem. I have a hidden edit area on my form. When the user clicks the Edit button, I set a bean property to true to display the area (this is a bit of a simplification) and set another bean property to the value being edited. This variable is referred to like:

<h:inputText value="#{bean.stringValue}" />

When the user cancels out of editing, I hide the edit area.

Let's say the user then wants to edit another item, but this one's value is the empty string (""). Using the same code, stringValue is set to the emptyString and the area displays.

However, the value from the previous edit is displayed, not an empty text box.

Without resorting to JavaScript, is there a way to make this work?

Edit: Following is as close as I can come to a SSCCE. As you see, I am activating in-place editing inside a table. I'm also using ICEfaces, but nothing special in this case.

<table>
<tbody>
    <ui:repeat var="cfi"
        value="#{evDetailBean.completeEvent.listCompleteCashFlowItems}">
        <ice:panelGroup rendered="#{!cfi.editThisOne}">
            <tr>
                <td>#{cfi.cfiName}</td>
                <td>#{cfi.absOfAmount}</td>
                <td>#{cfi.frequencyDescr}</td>
                <td>#{cfi.cfiToFrom}</td>
                <td>#{cfi.assetPoolName}</td>
                <td style="text-align: center"><h:commandLink
                        actionListener="#{cfi.editCfiListener}" value="Edit" />&#160;&#160;&#160;&#160;<h:commandLink
                        value="Delete" actionListener="#{cfi.deleteCfiListener}" />
                </td>
            </tr>
        </ice:panelGroup>
        <ice:panelGroup rendered="#{cfi.editThisOne}">
            <tr>
                <td><ice:inputText value="#{evDetailBean.newCFIName}"
                    style="width:118px;" partialSubmit="true" immediate="true" validator="#{evDetailBean.valNewCFIName}" /></td>
                <td>xxx</td>
                <td>xxx</td>
                <td>xxx</td>
                <td>xxx</td>
                <td style="text-align: center;"><ice:commandButton
                    value="Save" immediate="true"
                        actionListener="#{evDetailBean.saveEditCfiListener}"
                        styleClass="plumvo-button"
                        style="float:left; vertical-align: middle;" />&#160;&#160;&#160;
                    <ice:commandLink value="Cancel" style="vertical-align: middle;"
                        actionListener="#{cfi.cancelEditCfiListener}" /></td>
            </tr>
        </ice:panelGroup>
    </ui:repeat>
</tbody>

And this is the actionListener (in part):

public void editCfiListener(ActionEvent e) {

EvDetailBean evDetailBean = completeEvent.getEvDetailBean();

evDetailBean.setNewCFIName(this.getCfiName());

// initialize more fields

editThisOne  = true;    // This causes the row being edited to open up with modifiable fields.

}

Thanks in advance for your help.

2
Can you show how you reset the value to an empty String? Also, maybe you can show how the inputText is defind for the other items in the list for the view.Sully
Please show an SSCCE. There's apparently some misplaced term or ambiguity in the question.BalusC

2 Answers

0
votes

Just check in your bean after submit if stringValue is "" and if so, set it to null and visible property to false.

0
votes

the action , the bean function you are calling on click of edit button. inside that clear the stringValue variable.