2

I am trying to create a sql data table that can be fully edited and displayed on a single page. I am using jsf and a named bean. I use a arraylist bean object to store and display the data.

public List<RegionBean> getRegions()throws SQLException{

The data is displayed in an inputText element. When I try to update the information using a sql method in the backing bean it fails to add the updated text to sql data base. It will simply put the same value as was originally displayed. What I want to do is have the input text box display the data values from the array list and then store them in a different field in the bean after they have been edited.

Here is my code as it is now.

<h:dataTable value="#{regionBean.regions}" var="regions"/>


<h:column>
    <f:facet name="header">Region ID</f:facet>                       
    #{regions.regionID}
</h:column>
<h:column>
    <f:facet name="header">Region Description</f:facet>
    <h:inputText id="des" value="#{regions.regionDescription}">
    <f:ajax event="change" 
            listener="#{regionBean.updateText(event)}"
            render="des"/>
</h:inputText>
<h:column>
    <f:facet name="header">Save</f:facet>
    <h:commandButton action="#{regionBeanupdate(regions.regionID)}" value="Update">
    </h:commandButton>
</h:column>

The problem I am having with this UIComponent-ClientId=, Message=javax.el.PropertyNotWritableException:

In the bean I have

public void updateText(AjaxBehaviorEvent event)
            throws AbortProcessingException { }

How can I pass the new input text box value to this method so as I can store it as String in the bean and thus able to use it to update the sql database.

Please understand that I am familiar with sql and I have built several CRUD applications before and my question is not related to sql syntax or other wise.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user3698301
  • 21
  • 1
  • 1
  • 2

1 Answers1

1

Remove listener and render from <f:ajax> then add a valueChangeListener to <h:inputText>.

<h:inputText value="#{regions.regionDescription}" valueChangeListener="#{region.updateText}">
     <f:ajax event="change"/>
</h:inputText>

Then in your bean:

public void updateText(ValueChangeEvent event){
   input = event.getNewValue().toString();
}

Note: input is the variable in which the new value is stored.

Dapope
  • 128
  • 1
  • 9