I have created a data model in backingbean as shown at the image.
binded-data-model
And I created this ValueExpression:
tabla.setValueExpression("value", context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), "#{pc_BackingBean.listaDeTablas[" + String.valueOf(getListaDeTablas().size() - 1) + "]}", List.class));
However the row data is not changing when the form is submited.
I already make the string reference for the binding using recursive code (tested).
#{pc_BackingBean.listaDeTablas[" + String.valueOf(getListaDeTablas().size() - 1) + "]}"
but the next step that binds the row var with the data model does not work.
tabla.setVar("criterio");
"#{criterio.puntos}"
How can I properly bind the row/column data value with the correct variable in backingbean?
Edit:
The datatable is created in the backingbean.
I resolved the issue it seems is there a bug on the primefaces datatable method setColumns. When you use it the binding does not work properly.
Instead of use setColumns(columns) use getChildren().addAll(columns);
Related
Is partially rendering a single column in a collapsibleSubTable using #rows in RichFaces 4 possible?
For example this works with a single datatable.
List<Integer> updatedRows
render="myForm:myTable:#rows(updatedRows):id"
I'm not sure how to do this dynamically With a collapsibleSubTable.
render="myForm:myTable:#rows(updatedRows):mySub:#rows(updatedSubRows):id
Is it possible to pass the current iteration of updatedRows into updatedSubRows? Something along the lines of.
render="myForm:myTable:#rows(updatedRows):mySub:#rows(updatedSubRows(currentUpdatedRow)):id
Where currentUpdatedRow is updatedRows[0], updatedRows[1] and so on.
Or maybe using a HashMap<Integer, HashSet<Integer>>()?
I'm realizing my first application using JSF2 and Primefaces 5 .
I want that when the user press a button my managed bean creates a new DataTable and fill it with some data. How can I do that from my managed bean?
This is a part of code of my managed bean.
...
//This is the managed bean's method executed when the user presses the button.
public void execute() {
...
//Get the data from database and put the entries in a list of java beans called myList.
//Here I create a ListDataModel to convert myList in a DataModel to pass to the datatable
ListDataModel<myJavaBean> tableData = new ListDataModel<myJavaBean>(myList);
//Then I create a new datatable..
DataTable dataTable = new DataTable();
//.. and I set the data
dataTable.setValue(tableData);
//I define the columns
Column idColumn = new Column();
idColumn.setHeaderText("id");
Column dateColumn = new Column();
dateColumn.setHeaderText("date");
Column timeColumn = new Column();
timeColumn.setHeaderText("time");
Column stateColumn = new Column();
stateColumn.setHeaderText("state");
//Here I add the columns to the table
dataTable.getChildren().add(idColumn);
dataTable.getChildren().add(dateColumn);
dataTable.getChildren().add(timeColumn);
dataTable.getChildren().add(stateColumn);
...
When I press the button this part of code create a new DataTable with the correct number of columns and the correct header.
Also the number of row is correct but the row are completely empty, I suppose this is due to the fact that I have not bound the Columns with the respective java bean properties of the list. How can I do that?
So you want to create a UI component from a managed bean ???
Maybe I'm missing something here, but a proper and simpler way to acheive this is that the Datatable must be declared in facelet (your_page.hxtml) using <p:datatable> and link it to a backing bean containing the data (i.e. value="#{yourbean.yourlist}").
On startup, your backing bean can be empty. You just have to render UI differently, whether your data is loaded or not (see the "rendered" tag on the datatable component).
Just fill data into the bean when you have to do it (button/execute).
And do not forget to update UI parts (see "update" tag on your action button) in order to refresh altered page regions (datatable at least).
example:
<p:datatable id="mytable" var="child" value="#{mybean.children}" rendered="#{not empty mybean.children}">
...
</p:datatable>
...
<p:button update="mytable">
...
I have a GXT Grid showing some "User" objects. One of the columns holds checkboxes (CheckboxCell) . I need to disable a checkbox for 1 particular user and leave others enabled.
I tried extending CheckboxCell class - it's useless because it does not know the context (which User is renders): it only knows about true/false state.
tried
GridView view = table.getView();
Element cell = view.getCell(0, 1);
cell.setAttribute("disabled", "disabled");
-no luck. the disabled attribute is set on the outer "td" tag instead of the child "input" element.
tried cell.getChild..() methods - they all throw "method does not exist" exceptions.
UPDATE: I ended up creating my own CheckboxCellWhichCanBeDisabled class extending AbstractEditableCell. I'm afraid there's no other way.
I have a notes form with a series of fields such as city_1, city_2, city_3 etc.
I have an XPage and on that XPage I have a repeat.
The repeat is based on an array with ten values 1 - 10
var repArray = new Array() ;
for (var i=1;i<=10;i++) {
repArray.push(i) ;
}
return(repArray) ;
Within the repeat I have a custom control which is used to surface the fields city_1 through city_10
The repeat has a custom property docdatasource which is passed in
It also has a string custom property called cityFieldName which is computed using the repeat
collection name so that in the first repeat row it is city_1 and in the second it is city_2 etc..
The editable text field on the custom control is bound using the EL formula
compositeData.docdatasource[compositeData.cityFieldName]
This works fine but each time I add new fields I have to remember to create a new custom property and then a reference to it on the parent page.
I would like to be able to simply compute the data binding such as
compositeData.docdatasource['city_' + indexvar]
where indexvar is a variable representing the current row number.
Is this possible ? I have read that you cannot use '+' in Expression Language.
First: you wouldn't need an array for a counter. Just 10 would do (the number) - repeats 10 times too. But you could build an array of arrays:
var repArray = [];
for (var i=1;i<=10;i++) {
repArray.push(["city","street","zip","country","planet"]) ;
}
return repArray;
then you should be able to use
#{datasource.indexvar[0]}
to bind city,
#{datasource.indexvar[1]}
to bind street. etc.
Carries a little the danger of messing with the sequence of the array, if that's a concern you would need to dig deeper in using an Object here.
compute to javascript and use something like
var viewnam = "#{" + (compositeData.searchVar )+ "}"
return viewnam
make sure this is computed on page load in the custom control
I was never able to do the addition within EL but I have been very successful with simply computing the field names outside the custom control and then passing those values into the custom control.
I can send you some working code if you wish from a presentation I gave.
I have an ice:selectInputDate but the value of the component is not the same as in the backing bean. I have to select two different dates to successfully update the variable value of the backing bean.
What am I missing?
What I want to do is to populate a table after getting some data from the DB with the date as a filter.
You should post some code to get a better idea. Are you using a valueChangeListener and partialSubmit? If so, if you set the variable in the listener it would be the same in the bean as soon as you select the inputDate.
You can populate the table from the listener
for example:
public void dateListener(ValueChangeEvent evt){
yourDate = (Date) evt.getNewValue();
//get your data for the table
}