0

i am using jsf to develop an update form. I want to pass the custName to the bean by calling an edit method. My prblem is that i am getting the custName in the bean, but in the update.xhtml, the value is not displaying in editable format.

custmerDetails.jsf

<p:dataTable id="dataWork" var="work" value="#{customerBean.workList}" rowIndexVar="rownum" styleClass="#{not empty customerBean.workList ? '' : 'ui-helper-hidden' }"> 
<p:row>
<p:column>
<p:commandButton value="Click" action="#{customerBean.editWork}">
                            <f:setPropertyActionListener value="#{work}" target="#{customerBean.selectedWork}" />
</p:commandButton>
</p:column>
</p:row>
</p:dataTable>

Now in the bean: (i have getters and setters for custName in the bean)

public void editWork() {
        FacesContext fc=FacesContext.getCurrentInstance();
        try{
            this.custName = selectedWork.getCustName();
            System.out.println("Name:: " + custName);
            ExternalContext context=fc.getExternalContext();
            context.redirect(context.getRequestContextPath() + "/update.jsf");
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

In the update.xhtml page:

<p:panelGrid id="edit_work_dtls" style="float:left;overflow-x: auto;overflow-y: auto; width: 700px;">
<p:row>
<p:column width="25%;">
<h:outputText value="Customer Name:" />
</p:column>
</p:row>
<p:row>
<p:column width="25%;">
<p:inputTextarea rows="6" cols="20" value="#{customerBean.custName}"></p:inputTextarea>
</p:column>
</p:row>
</p:panelGrid>

I am not find a way out to display the custName in editable format in the update.xhtml

user1685091
  • 59
  • 2
  • 4
  • 10
  • 1
    What does "editable format" mean? An inputTextarea is editable. What is the scope of your bean? – Selaron Dec 20 '18 at 08:21
  • Bean is ViewScoped. Editable format means in the inputTextArea, value of custName is not coming from the bean. I also tried changing the scope to SessionScoped, still no luck. – user1685091 Dec 20 '18 at 08:29
  • 1
    So the textArea remains empty? Did you Debug your code? ViewScope won't work because it get's lost after your redirection. SessionScope should work, but prevents the user from editing multiple items in multiple browser tabs. In order to pass data through redirects you should research and try out FlashScope. But beware Mojarra had problems on that topic: https://stackoverflow.com/questions/9148798/object-in-flash-scope-is-not-available-after-redirect – Selaron Dec 20 '18 at 08:46
  • yes, i debug the code. In the bean the custName has value, but in the jsf, inputTextArea remains empty. – user1685091 Dec 20 '18 at 09:36

0 Answers0