I have a dataTable that is populated using my Bean. I am only wanting to display the first 15 results, then allow the user to use a next button that will display the next 15 results. Here is my dataTable
<h:dataTable id ="data" value="#{copd.getCopds()}" var="c"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row">
my CopdBean has an int value called pageNumber that it passes down to be used with the CopdDaoImpl to determine the results for the table. Here is a quick path down the backend...
CopdBean.java
public List<Copd> getCopds(){
return copdBo.findAllCopd(pageNumber);
}
copdBoImp.java
public List<Copd> findAllCopd(int pageNumber) {
return copdDao.findAllCopd(pageNumber);
}
copdDaoImp.java
private static int pageSize = 15;
public List<Copd> findAllCopd(int pageNumber){
Criteria crit = getSession().createCriteria(Copd.class);
crit.add(Restrictions.like("copdPK.upi","0%"));
crit.addOrder(Order.desc("copdPK.upi"));
crit.setFirstResult(pageSize * (pageNumber -1));
crit.setMaxResults(pageSize);
return crit.list();
}
So as you can see, when the pageNumber int value is updated, the copd.getCopds() will display the next 15. When i hard code and change the int value to say 2, 3, or 4 and run the webapp, everything displays correclty. I'm just needing button functionality that will update this pageNumber value, and refresh the dataTable(aka recalling the copd.getCopds() and storing that result as 'value' in the dataTable.
I have a commandButton labeled Next that will call a method to update my pageNumber int value. But when this button is clicked nothing happens. I have even ran in debug and it seems the method is never called.
<h:commandButton value="Next" action="#{copd.nextPage()}"/>
copd.nextPage() just increases the int value by 1. However clicking this button does nothing. I have tried
onclick="refreshTable()"
with
<script type="text/javascript">
function refreshTable()
{
var table = document.getElementById("data");
table.refresh();
}
</script>
I have also tried <f:ajax render="data"/>
Everything works for my application, i'm just trying to basically update the 'value' in the dataTable and then refresh the dataTable without the whole page refreshing(which i'm told will then start over with a new bean) so that i'm only displaying 15 rows at a time vs. all 150 or 200 or 4000. Any help is greatly appreciated as I know its just something simple i'm missing on my front end dataTable.
Related
So I am trying to make the Next button only visible when the user chooses a rating, but every time I apply one of these codes:
If(Rating2.Value = 0; DisplayMode.Edit; Disabled) or If(Form9_3.Valid; DisplayMode.Edit; Disabled)
The Next button stays grayed out... Any ideas on how to do this better?
https://i.stack.imgur.com/S0OlI.png
Your function right now likely is on the button's Display Mode property. You want to put your function on the button's Visible property.
If(Rating2.Value = 0; false; true)
Make sure the default value of your Rating component is set to zero.
I have a Datatable that shows me some values from my DB. I added some buttons like edit, mail, etc. I'm trying to implement a button called "PDF" when i press, must show a modal window with the PDF previously generated by another button.
I tried with <p:media /> and <pe:documentViewer /> even to get the PDF directly on a xhtml like this:
<p:media value="C:\route\mypdf.pdf" />
To get the path and the name of the file, i have these lines on my Bean.
String exportDir = System.getProperty("catalina.base") + "/OrdenesRetiro/";
String nom_archivo = "Orden_de_Retiro" + or.getCod_ordenretiro() + ".pdf";
The or.getCod_ordenretiro() get the ID from my datatable and stores on a String value. I tried with document viewer extension and another forms, but really no clue, especially because i have to get the value of the datatable that stores on or.getCod_ordenretiro()
Any sugestion?
I have two edit boxes in an XPage and one label.
Leave Start Date : EDIT BOX
Leave End Date : EDIT Box
Holidays Taken : label
I want to calulate the diffence in dates and get it computed in the label using the following code in onChange event of second(Leave End Date) edit box but on chaging the value of the edit box it clears the two field and nothing gets computed:
var leaveStartDate = document1.getValue("fld_Leave_Start_Date1");
var leaveEndDate = document1.getValue("fld_Leave_End_Date1");
var difference = null;
try{
var nDateStart = session.createDateTime( leaveStartDate );
var nDateEnd = session.createDateTime( leaveEndDate );
difference = nDateEnd.timeDifference(nDateStart);
difference = (Math.floor(difference/86400)) + 1;
}catch(e)
{
return e
}
document1.setValue("fld_NoOfDays",difference);
I tried getComponent("fld_Leave_Start_Date1").getSubmittedValue(), but didn't work either.
Can someone please help.
Thanks a lot in advance!
If the edit boxes are getting cleared, it sounds like you've set the event to do a full refresh instead of a partial refresh.
The other possible cause of clearing fields is if you're using Partial Execution Mode (execMode="Partial" in the source pane for the eventHandler) but have specified a execId that does not include the two edit boxes. (Partial Execution by default runs on the current component, so you should not lose the values of that Edit Box.) But I don't think that's the case.
Can someone hint me on how to utilize selection functionality of extendeddatatable in rich:datatable ?
My requirement is each row contains more than 15 columns and all are editable and should be able to scale upto 3000 records in a page.
I'm using JSF 1.2 and richfaces 3.3.3.final with spring webflow.
To use the selection attribute on extendeddatatable:
Declare in your view
<rich:extendedDataTable id="xxxDataTable" value="#{xxxBean.listXxxDataModel}"
var="xxxItem" selectionMode="single" rows="3" width="800px" height="100px" noDataLabel="#{msg.dataTable_noDataLabel}"
selection="#{xxxBean.xxxSelection}">
Bind your dataTable value to ExtendedTableDataModel : use a org.richfaces.model.DataProvider to provide data to the ExtendedTableDataModel.
ArrayList<XXX> values = ...;
XXXDataProvider xxxDataProvider = new XXXDataProvider(values);
ExtendedTableDataModel<XXX> xxxDataModel = new ExtendedTableDataModel<XXX>(xxxDataProvider);
The selection is binding to
/** Binding selection */
private SimpleSelection xxxSelection;
Last, to retrieve the selected object from your dataprovider :
key = xxxSelection.getKeys().next();
selectedObject = xxxDataModel.getObjectByKey(key);
I've created a custom edit form as a simple aspx page in VS2010 (inherits from LayoutsPageBase) which uses the SharePoint Web controls LookupField control to display a drop down list of values from a custom type
The form displays correctly with the drop down box containing the expected range of values
The ControlMode is set to the same as the FormContext (though I have tried explicitly setting this to Edit)
But on the postback the value of the dropdown list is not set - the selected item index is set to -1
How can I correctly use the LookupField control to capture a selected value from the user?
Could it be because I'm adding the controls declaritivly in the aspx and then setting the list id etc from the SPContext in the page load event? - see code snippet below (not the prettiest but just trying to get it to work at this point):
from aspx:
<SharePoint:FileField ID="FileNameText" InputFieldLabel="Name" runat="server" ControlMode="Display"/><br />
<SharePoint:LookupField ID="FeedType" runat="server" />
<SharePoint:TextField ID="FeedStatus" runat="server" />
....
in the code behind page load:
if (!IsPostBack)
{
SPItem feedFileItem = SPContext.Current.Item;
FileNameText.ControlMode = SPContext.Current.FormContext.FormMode;
FileNameText.ListId = SPContext.Current.ListId;
FileNameText.ItemId = SPContext.Current.ItemId;
FileNameText.FieldName = "Name";
FeedType.ControlMode = SPControlMode.Edit;
FeedType.ListId = SPContext.Current.ListId;
FeedType.ItemId = SPContext.Current.ItemId;
FeedType.FieldName = "FeedType";
FeedStatus.ItemContext = SPContext.Current;
FeedStatus.RenderContext = SPContext.Current;
FeedStatus.ControlMode = SPControlMode.Edit;
FeedStatus.ListId = SPContext.Current.ListId;
FeedStatus.ItemId = SPContext.Current.ItemId;
FeedStatus.FieldName = "FeedStatus";
}
UPDATE
Ok I managed to get my form working by adding the controls in the code behind in the override of CreateChildControls - this is in line with the majority of the samples I've seen on the net.
But can someone explain why my approach didn't work and whether I can do this all in a declarative way in the aspx?
During postbacks selected values from lists are simply ignored if the list control isn't populated. So if you choose item 2 and the list items are null it will simply ignore the response parameter and not set the Value property. This is because ProcessPostData occurs prior to LoadData. Even if you were to remove the !IsPostBack on the LoadData method it still wouldn't work because ProcessPostData still occurs before LoadData and you didn't load the list prior to processing the postback.
A simple way to fix this is move your initialization code into the EnsureChildControls method of your Application page.
protected override void EnsureChildControls()
{
base.EnsureChildControls();
...
FeedType.ControlMode = SPControlMode.Edit;
FeedType.ListId = SPContext.Current.ListId;
FeedType.ItemId = SPContext.Current.ItemId;
FeedType.FieldName = "FeedType";
...
}