Bean values are not refreshing on p:datatable after update

jQuery UI Widgets
Post Reply
dipak.upwanshi
Posts: 2
Joined: 12 Jan 2017, 14:33

12 Jan 2017, 15:41

Hello all,

I should say Thanks a lot in advance for reading my problem before I start explaining it. Appreciate your response on this post.

Problem in brief: Value in the fields are not getting refreshed after update action on add/delete button. Its taking values from cache. And if I manually refresh the url, expected result is coming on page. The bean class is reflecting values correctly at backend. Update action of button is not refreshing bean values on page.

Details
I have a p:datatable component on my xhtml page.
This is input datatable with 2 columns as calendar field and 1 inputText field and 1 checkbox (to select for deletion).
I have 2 command button on page to add rows and delete rows respectively.

Action to recreate the problem:
1. I add 4 rows, fill values in all fields.
2. Select checkbox of 1st and 3row to delete.
3. Expected result: 2 rows with data of 2nd and 4th row.
4. Actual result: 2 rows with data of 1st and 2nd row.
5. Add 2 rows by add button
6. Expected result: 2 new blank rows added
7. Actual result: 2 rows added with old data of 3rd and 4th row.

Please let me know if you need any further information/input from my side

Code: Select all


::::::Bean class content:::::::
/**
	 * Add new Outage Profile
	 */
	public void addOutageProfile(){

		List<OutageProfileBean> outageProfiles = this.detail.getOutageProfiles();
		
		if(numberOfOutSegToAdd > 0 && (outageProfiles.size()+numberOfOutSegToAdd)<200){
			for(int i=0; i<numberOfOutSegToAdd; i++){
				outageProfiles.add(new OutageProfileBean());
			}
		} 
		
	}
	
	 /**
	  * Delete outages
	  */
	public void removeField(){
		
		List<OutageProfileBean> outageProfiles = this.detail.getOutageProfiles();
		 
		Iterator<OutageProfileBean> outageProfilesItr = outageProfiles.iterator();
		
		while(outageProfilesItr.hasNext()){
			
			OutageProfileBean individualOutageProfile = outageProfilesItr.next();
			if(individualOutageProfile.isDelete()){
				outageProfilesItr.remove();
			}
		}
		
	 }

Code: Select all

::::xhtml code::::
<p:tabView>
<p:tab id="outageProfilesTab" title="Outage Profiles">
						<p:dataTable value="#{RemitBean.detail.outageProfiles}"
							var="field" id="repeat" rowIndexVar="index" style="width: 100%;"
							paginator="true" rows="20"
							paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
							rowsPerPageTemplate="10,20,50" lazy="true"
							widgetVar="reportTable" scrollable="true" scrollHeight="250">
							<p:column style="white-space: normal;" headerText="Segment Count"
								width="6%">
								<div style="text-align: center;">
									<f:facet name="header">
									</f:facet>
									<h:outputText value="#{index + 1}" size="2" />
								</div>
							</p:column>
							<p:column headerText="Outage Segment Start" width="21%">
								<p:calendar id="outageSegmentStart"
									value="#{field.outageSegmentStart}"
									pattern="yyyy-MM-dd HH:mm:ss" showOn="button"
									required="#{RemitBean.outageProfileValidation}"
									requiredMessage="Segment Count '#{index + 1}' Outage Segment Start is required">
									<!-- <f:ajax execute="@this" /> -->
									<p:ajax event="dateSelect"
										listener="#{RemitBean.calculateDateDifference}"
										update="outageDuration" />
									<p:ajax event="change"
										listener="#{RemitBean.calculateDateDifference}"
										update="outageDuration" />

									<f:attribute name="outageProfileDate" value="#{field}" />
									<f:attribute name="selectedOutageProfileIndex" value="#{index}" />
									<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" />

								</p:calendar>

							</p:column>
							<p:column headerText="Outage Segment End" width="21%">
								<p:calendar id="outageSegmentEnd"
									value="#{field.outageSegmentEnd}" pattern="yyyy-MM-dd HH:mm:ss"
									showOn="button" required="#{RemitBean.outageProfileValidation}"
									requiredMessage="Segment Count '#{index + 1}' Outage Segment End is required.">
									<!-- <f:ajax execute="@this" /> -->
									<p:ajax event="dateSelect"
										listener="#{RemitBean.calculateDateDifference}"
										update="outageDuration" />
									<p:ajax event="change"
										listener="#{RemitBean.calculateDateDifference}"
										update="outageDuration" />
									<f:attribute name="outageProfileDate" value="#{field}" />
									<f:attribute name="selectedOutageProfileIndex" value="#{index}" />
									<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" />
								</p:calendar>
							</p:column>
							<p:column style="white-space: normal;"
								headerText="Outage Duration" width="14%">
								<p:inputText id="outageDuration" value="#{field.outageDuration}"
									size="15" disabled="true" />

							</p:column>
							<p:column style="white-space: normal;"
								headerText="Installed Capacity" width="8%">
								<p:inputText id="installedCapacity"
									value="#{RemitBean.detail.normalCapacity}" size="6"
									disabled="true" />
							</p:column>
							<p:column style="white-space: normal;" headerText="Capacity"
								width="8%">
								<p:inputText id="outageCapacity" value="#{field.capacity}"
									size="6" required="#{RemitBean.outageProfileValidation}"
									requiredMessage="Segment Count '#{index + 1}' Capacity is required.">
									<f:ajax execute="@this" />
								</p:inputText>
							</p:column>
							<p:column headerText="Delete"
								style="text-align:left;vertical-align:top;" width="50">
								<div style="text-align: center;">
									<p:selectBooleanCheckbox id="deleteUomfSegmentId"
										value="#{field.delete}">
										<f:ajax execute="@this" />
									</p:selectBooleanCheckbox>
								</div>
							</p:column>

							<br />
						</p:dataTable>


						<p:spacer width="1" height="10" />
						<p:outputLabel for="numOfOutSegToAdd"
							value="Number Of Outage Segment to Add: " />
						<p:inputText id="numOfOutSegToAdd"
							value="#{RemitBean.numberOfOutSegToAdd}" size="13">
							<f:ajax execute="@this" />
						</p:inputText>

						<p:commandButton value="Add Outage Segment"
							actionListener="#{RemitBean.addOutageProfile}"
							process="@this, :mainForm:tabViewHeader:repeat"
							update=":mainForm:tabViewHeader:repeat" immediate="true">
							<f:param name="skipValidation" value="false" />
						</p:commandButton>
						<p:commandButton value="Delete Selected Outage Segment"
							actionListener="#{RemitBean.removeField}"
							process="@this, :mainForm:tabViewHeader:repeat"
							update=":mainForm:tabViewHeader:repeat" immediate="true"
							align="right">
							<f:param name="skipValidation" value="false" />
						</p:commandButton>

					</p:tab>
				</p:tabView>



rok7
Posts: 10
Joined: 02 Mar 2016, 15:48

13 Jan 2017, 15:43

Your question is about PrimeFaces, not PrimeUI, so you should post it to the 'JavaServer Faces' - forum.

dipak.upwanshi
Posts: 2
Joined: 12 Jan 2017, 14:33

14 Jan 2017, 06:26

Thanks for re-rotuting to correct section. I have got the solution.

dvarshney86
Posts: 1
Joined: 28 Jan 2017, 08:02

28 Jan 2017, 08:06

Can you please advise what was the solution to this problem?

Post Reply

Return to “PrimeUI”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests