I have a View which extends GridLayout and has a 2x2 - Matrix.
Now I want to programmatically remove a component in one of the cells of the GridLayout with:
this.removeComponent( component );
But the component doesn't get removed at least the browser view doesn't get updated.
I also used:
this.removeComponent( col , row , component );
But the problem is still the same.
UPDATE: When I first do a component count :
int c = this.getComponentCount();
I get four.
After the removeComponent I get THREE - so it get's removed but the browser doesn't reflect this.
Any ideas what the problem could be?
Your problem is a sync problem, the client doesn't get notified from your server, so he doesn't know that this gridlayout has changed.
So the client is not updating his view.
To fix this, you can use #Push annotation or add a "refresh" button.
Push (see Doc) allows you to call client actions from the server to update view. The problem you are actually having is that your element is not removed after a client action, so the client is not waiting for a content update, so nothing is updated.
Related
I found this question, but it does not appear to be resolved, and I also have more to add.
First off, the linked question defines pretty much the same issue that I am having.
1. I am using the application layout control from the ExtLib
2. It does not matter if the button is in that control or not.
3. CSJS actions will fire from the button, SSJS actions will not fire.
4. No errors are present
5. Browser / cache is irrelevant as the server side action just will not fire.
After seeing the linked question, I looked in the Local file in the package view and found an anomaly that makes me wonder if it could be the cause. I have never seen such a file before and even looked in my other xpage projects just to be sure.
This file cannot be deleted, and when clicked upon, the display window says that the element does not exist.
Does anyone know what this file is, how I can remove it, or could it be that my application is corrupted?
**More Info **
The following snippet is copied from the java file for the XPage located in the Local directory. Everything looks fine to me.
private UIComponent createEventHandler(FacesContext context,
UIComponent parent, PageExpressionEvaluator evaluator) {
XspEventHandler result = new XspEventHandler();
String sourceId = "button2/xp:eventHandler[1]/xp:this.action[1]/text()";
MethodBinding action = evaluator.createMethodBinding(result,
"#{javascript:view.postScript(\"alert(\'server script fired!\')\");}",
null,null, sourceId);
result.setAction(action);
result.setSubmit(true);
result.setEvent("onclick");
result.setRefreshMode("complete");
return result;
}
EDIT
Moving all of the design elements into a new .nsf so that file is no longer present does not change the problem of the SSJS onclick action not firing. That strange file is however not present.
Is it failing on a converter / validator? That can cause it to skip out of the lifecycle before Invoke Application phase. To test whether a button is actually working, you can also use "Do not validate or update data". Then the SSJS runs in Apply Request Values phase. If the SSJS is triggered (you won't have the latest data from the browser in the data model or components though), then it's another good bet for converter or validator failure.
OK, so I'll express what I'm doing in bullet points without code (as I'm in a massive muddle)...
Using a single-page application with <p:layout> consisting of <p:layoutUnit>s (in different pages brought to main page using <ui:include>)
One of these <p:layoutUnit>s is a single <p:dataTable> updating dynamically (also it's a dynamic dataTable based on selected single-row and associated <p:commandButton>
Rest of the <p:layoutUnit>s update dynamically based on actions happening in dataTable (they contain buttons whose actions (presently not defined) update with change in dataTable data and dynamic 'header text')
dataTable uses dynamic columns (as data to be shown changes, if it helps, data is in a 'tree structure' and I navigate 'up' and 'down using buttons (common 'back' in header) and 'next' <p:commandButton> for each row)
Now to the actual problem
When I use the 'next' button to go to the next level of data in the tree, let me illustrate what happens:
Root -> 'Next' -> Goes to Child -> data updated
Child -> 'Next' -> No action -> Use one of the non-dataTable buttons with no function defined -> default JSF/PF action is Page Refresh -> data updated
'Next' -> Goes to Child
Why does this happen? Why does the 'no action' period happen in between? I feel like I'm missing something here. It's never happened before. None of the controller's functions are triggerable at that time. I've checked this by using the debugger in my IDE. I'm 100% sure it's a problem with the dynamic dataTable. But I don't understand why as I've initiated Column Controller in the 'preRenderView' stage using <f:event>
Also using an 'id' for the body in the Main Index Page and updating using RequestContext just makes the page blank.
I've tried multiple combinations of View and Request Scopes for the Column Controller and used a 'PreViewRender' event listener in the dataTable to initiate the Column Controller. All of my efforts.
One particular combination (IIRC **NOT ** using the PreViewRender listener causing even the data to not be updated in the dataTable, forget non-functioning of <p:commandButton>s or <p:remoteCommand> on <a> onclicks.
As there is a huge amount of code spanning this and am in a muddle myself now, I'll add code when you make some headway.
OK, I found the answer!
https://stackoverflow.com/a/2120183/3488113
This is user BalusC's answer where one of the main reasons he suggests is JS error.
I am calling a JavaScript function from the Bean which does not exist/returns some error. Removing references to it in the Bean has solved the problem for the time-being.
I assume the rest of the update actions stop/frontend component JS action changes are not loaded/actions itself are not loaded if there is a JS error in the backend call, which is the real cause.
I used an ice:dataTable component to display data, somehow there was a default onscroll event in the target div which doesn't make any sense to me and it had brought some positioning problems to other float elements within the page. I want to disable this action, but I didn't find any approach to control this.
It called the function below:
var input = document.getElementById('targetId'); clearTimeout(ice.pid);
ice.pid = setTimeout(function() {
input.value =
document.getElementById('targetId_scroll').scrollTop;
window.iceSubmitPartial(null, input, event);
}, 400);
I had a similar problem with ICEFaces and as we upgraded the JSF and ICEFaces versions the best solution was to change the tags:
ice:dataTable tag to ace:dataTable and the columns inside from ice:column to ace:column.
But, if you didn't upgrade ICEFaces version, I guess you could use a JavaScript or jQuery in some point of your code removing the onscroll attribute, like:
document._getElementsByXPath("//div[contains(#onscroll,'scroll')]")[0].removeAttribute("onscroll")
This one isn't a good one, just a example, cause you can remove scroll from other tables.
jQuery('.myClass div[id$="_scroll"]')[0].removeAttribute("onscroll")
I have a problem that have me stumped.
I have been searching for a solution, but haven't found a working one yet. The solutions I seen introduces other issues.
Here is the scenario:
I have a frameset with two frames: 'Navigator' and 'Main'.
In the 'Navigator' frame I display a form called 'Navigator'. It contains an outline, to display a menu.
In the 'Main' frame I display the view selected by the user in the navigator.
So this is a very traditional Notes client application.
I now want to add a checkbox at the top of the view (in the action bar), allowing the user to filter the view by his/her own name. I use #SetViewInfo for this, and it all works perfect.
The issue is when the user switch views. The #SetViewInfo filter stays active when switching to a different view, so after some searching I found some solutions:
In http://www-01.ibm.com/support/docview.wss?uid=swg21204481 IBM suggests to put the following code in the QuerySave event:
#SetViewInfo([SetViewFilter]; temp ; 0 ;1)
When I am switching view or closing the view, I get the error message "Cannot execute the specified command".
In http://www-10.lotus.com/ldd/bpmpblog.nsf/dx/using-setviewinfo-in-a-notes-client-application-to-create-a-user-specific-view Andre Guirard suggests to put the following code in the QuerySave event:
#SetTargetFrame("frameName");
#UpdateFormulaContext;
#Command([OpenView]; #Subset(#ViewTitle; -1));
#SetViewInfo([SetViewFilter]; ""; "columnName"; 1)
I modify this to match my frame name and the programatic name of the first column in my view:
#SetTargetFrame("Main");
#UpdateFormulaContext;
#Command([OpenView]; #Subset(#ViewTitle; -1));
#SetViewInfo([SetViewFilter]; ""; "Adjuster"; 1)
This works perfectly when switching between view. But when I close the application while I am in this particular filtered view, the application is re-opened automatically. This happens no matter if the filter is enabled or not when closing the view.
However, when the view repopens, the frameset is not reloaded, it is just the view with the built-in view navigator to the left.
I finally got this to work by (in the built-in view navigator) selecting another view that the one where I filter data. This fixed the issue for a while, but then it starts again, and the filtered view is active in the navigator.
Obviously it is the OpenView command that is causing this, but if I remove just that line, I get the "Cannot execute the specified command" error again.
Any suggestions/pointers? I am using Notes 8.5.3 running on Windows 7 Professional.
This question can also be found in the IBM developerWorks forum for Notes 8.5:
http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllThreadedWeb/08c73910571306c485257b2b0061ef91
First thing, I would suggest to make sure your view frame is always called "NotesView". You will have much less compatibility issues if you do this.
Secondly, I presume when you say you put it in the QuerySave event you really mean the QueryClose event? Views do not have a QuerySave event.
Thirdly, I find the #UpdateFormulaContext line is not needed. This is what I have in my view QueryClose...
#SetTargetFrame("NotesView");
#Command([OpenView]; #Subset(#ViewTitle; -1));
#SetViewInfo([SetViewFilter]; ""; "<programmaticColumnName>"; 1)
And I can close the app while in the view without any problems.
I am using the Telerik MVC grid, with Ajax data binding.
I would like to do 2 things with the Telerik MVC Grid:
When a row is selected, detect (client side) which page the grid is currently on as well as which row was selected.
The next time the grid is loaded (using ajax ... I never leave the page), page back to the same page to show the last select. (I guess I am really just asking if there is a way to immediately go to a page of the grid once the data is loaded, rather than page 1)
Please keep in mind, I am aware of the client side events already. I would like to know how to do #1 from the event, and #2 either from the client side or programatically somehow.
Edit/More Details: I think I know what I need to do here. Since I am using Ajax loading here, the Ajax POST is being called somewhere in the Telerik code. I can see that during that Ajax POST they are sending a "page" parameter to the controller. If I could edit that somehow, I am sure it would work - but I am having trouble changing that parameter.
Thanks in advance!
For the sake of anyone else looking for this, I figured it out:
Getting the current page of the Grid:
To do this, I use jQuery to determine which number has the "selected" style (t-state-active) to determine the current page number. Example (my grid id is 'cases-grid'):
function getCurrentGridPage() {
///<summary>Gets the current page of the #cases-grid</summary>
var page = $('#cases-grid .t-state-active');
if (page.length == 0) {
return 1; //default to page 1 when unknown
}
return page.text();
}
The second part of my question was actually well documented on the Telerik site ... I just missed it for awhile. To load the grid to a specific page (other than 1) I added the following to my grid:
.Pageable(pager => pager.PageTo(#Model.InitialPage))
And added the InitialPage property to my model.