Wicket Table css not rendered after ajax update? - java

I have a datatable with some items. The datatable has some css on the table tag. When I update the dataproviders model list and send the component back with ajax the css doesn't get rendered.
However if I send the entire page using ajax the table is rendered correct.
Example:
<wicket:panel>
<table class="striped">
</table>
</wicket:panel>
This css class gives odd and even a different css.
This is how I update the component after changing the dataprovider.
ajaxRequestTarget.add(MyPage.this.get("myPanel")); //this panel contains the table
The data gets added but the css markup is gone.
Refreshing the page brings back the css.
ajaxRequestTarget.add(MyPage.this); //send the entire page
This works but the entire page gets refreshed(and this make the page scroll up.
Whats the difference in component rendering if you send the entire page, instead of only 1 component/panel?
I'm using chrome.

If you render styles via jQuery, you'll have to call it again to re-paint correctly.
ajaxRequestTarget.appendJavascript("renderMethod('.striped');");

Related

What may I be missing for showing search result in a table on a second frame in a JSP page?

I have a JSP page that after searching, and getting a result from backend, should display a table in a frame below the first frame, containing search fields and buttons etc. I get all results from backend (shown in sysout) but I am missing something because my table is not displayed. In fact I believe the whole second frame is not shown.
First JSP containing both frames:
</head>
<frameset border="0" cols="100%" rows="100%">
<frame name="eoSupersessionHeader" src="/glopps/processEoSupersession.do?method=initializeForm" noresize="noresize">
<frame name="eoSupersessionResult" src="/glopps/jsp/extendedOffer/eoSupersessionTable.jsp" noresize="noresize">
</frameset>
<NOFRAMES><BODY><P>To view this page, you need a browser that supports frames.</P></BODY></NOFRAMES>
<noframes>
When debugging using F12 I find that my second frame, the one containing my table, isn't loaded/doesn't containg any HTML code at all, whilst the first one contains its HTML.
Any sggestions as to what I might have missed or what I might need to add?

Wicket implementation of bootstrap-wysiwyg

Im trying to figure out how to create a wicket component wicket could represent a div that is then used by the Bootstrap-wyiswyg javascript. Once the page is submitted i want to be able to get the content of the div and have that represented on the server, in a IModel<String>.
The part im struggling with is getting the content from the div to the server-side. For instance if i used a textarea i would just have my component extends TextArea and that would do all of this for me. So really what im asking is whether there is a wicket component that i can add as a <div wicket:id="mycomponent"></div> but onsubmit populate the component's Model with the content of the div from the client-side. Or do I have to write all this code myself?
You can try adding a normal "wicket" textarea to your form (with display: none) and add a jQuery handler for the form's submit event that will do something like:
$('your-text-area-selector').html($('your-wysiwyg-div-selector').html());

Set value for a html label from a servlet

I'm not sure Is this possible ?
but, I have a label in html page.
<label name='example'>Page 1</label>
I want to update the label value to something else after i get to another page from my controller servlet:
<label name='example'>Page 2 (update being update from servlet)</label>
Can anyone understand my question and help?
It is not possible to directly update it as a servlet from Page 2 can only write response to Page 2 .
However you can use session to share/update data between pages , update the session variable in page 2 and auto-refresh the page one every few second to reflect that change.
If you were opening a child window however then you can use the JavaScript on child window to update the items on Parent page.

Update iframe in container page on submit of <form> in container page

I have a main html page which contains an IFRAME.
I have a server side jsp code that is displayed with some default values inside the IFRAME for the first time.
Whenever a person tries to use a search button in the main page the results are displayed in the IFRAME updating its content.
I have a servlet that does the calculation on the searched data and updates the IFRAME content.
The problem:
I have used the sendRedirect method in servlet to refresh the IFRAME but to no avail.
The string I am passing to sendRedirect is /results.jsp?search=value&size=1 (jsp to be displayed in iframe).
The servlet does its calculation work properly but opens a new page in place of the mainpage: not a desired output.
The mainpage with its interface should remain there, only the IFRAME should refresh.
My question:
Is this the correct method to refresh an iframe? If not kindly tell me what should I use to update my iframe (jsp) via servlet.
PS: Please forgive the absurdity of the quesion if any. I am new to the jsp-servlet.
Any help is much appreciated
When you do a redirect using response.sendRedirect() method, the actual 'frame' where the servlet was called will be modified. That frame can be the entire page, or an iframe, or even the legacy frames used in javadocs.
As #Jake223 said, set the target attribute to the iframe name in the form:
If you are using a form to submit the information, then you do something like this:
<iframe name="resultframe"></iframe>
<form action=[path to servlet] target="resultframe">
<input type="text" name="searchq"/>
<input type="submit" value="search"/>
</form>
If you are using javascript to create the iframe, then use the src attribute of the iframe:
<iframe src=[path to servlet]?[request params]></iframe>
If the search mechanism is an HTML form, you can set the target attribute of the form to the name of the iframe in question. See W3Schools's page on this for more details.

Display page data on same page without forwarding it to another page

In my webpage (Eg Link1: http://localhost:8086/MyStrutsApp/login.do) I have several links. When a user clicks on one of the links, he is taken to another page (Eg link2: http://localhost:8086/MyStrutsApp/AddBook.jsp) to fill an html form.
Now what I want to achieve is that when any user clicks on the link, that html form (Link2) is displayed on the same page (i.e. Link1).
I have no idea how to achieve this.
The AJAX way to achieve this is the following:
you have a DIV on your original page that will be replaced (i.e., either has content that only makes sense in the original context or completely empty)
your Link2 servlet produces only the contents of the above DIV (and not the contents of that page)
you use a tiny bit of Javascript to make an AJAX call and fill the DIV with the response.
If you want to use Dojo, the HTML page would look like this:
<!-- main content -->
<div id="leftpanel">
<h3>This content will be replaced</h3>
You can add a book
</div>
The Javascript code would look like this:
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js" type="text/javascript"></script>
<script type="text/javascript">
function display_wait(s) {
var mainPanel=dojo.byId("leftpanel");
mainPanel.innerHTML='<div class="waitingmsg">'+s+'</div>';
}
function updateFromURL(url) {
display_wait("loading content");
dojo.xhrGet({url:url,
load:function(result) {
dojo.byId('leftpanel').innerHTML=result;
}});
}
</script>
(As Rafa mentioned, you can use the same technique to display the new part in a dialog)
You can always use jQuery to present a dialog ... http://jqueryui.com/demos/dialog/
Retrieve the page with AJAX and present it inside the dialog.
To display one page within another, use an iframe. See the iframe docs.
To make a link on the outer page load its target page into the iframe, give the iframe a name attribute, and give the link a matching target attribute.

Categories

Resources