Refresh only update panel on parent from pop-up window - java

I have a button which opens a pop-up window and an Ajax update panel. Inside that window I have another button.
What code do I have to run if I want that update panel to be refreshed, when I press the button from the parent page, without refreshing the whole page?
I sow this code on a web which refreshes the page:
<div id="Container" onclick="__doPostBack('UpdatePanel1', '');">
I am such a good friend with Java.

You need to utilize window.opener object.
window.opener.document.getElementById('Container').onclick();
I'd suggest using jQuery to ensure cross-browser compatibility. And also adding some null-checks of course.

Use Jquery :
If the DIV ID remains static :
$("#Container").click(function() {
// REFRESH CONTAINER HERE
});
If the Div ID is dynamic then make use of class instead of ID:
$(".Container").click(function() {
// REFRESH CONTAINER HERE
});

Related

Vaadin: How to navigate without reloading the page?

I have to navigate between my components and I use a custom button like this:
button.addClickListener(click -> {
UI.getCurrent().navigate(ClassToNavigate.class);
});
The url does refresh in the search bar but it only shows a black page, I've to hit F5 to see the component in my parent layout.
My only fix is to add:
UI.getCurrent().getPage().reload();
...which reloads the page after navigating to the URL, and that breaks the UX in my opinion, however... when using a BeforeEnterEvent on a class and using the method:
forwardTo(ClassToNavigate.class);
redirects perfectly... although I can't have BeforeEnterEvent for every menu button I have, I can't see why forwardTo() works perfectly and navigate() doesn't.
Is there a way to navigate without having to reload the page? And without using RouterLink which I can't because I'm already using a custom component.
Thanks in advance!

How can disable the selected link when clicking another in wicket ?

i have a bunch of links like this :
<li wicket:id="LIlink">Link name</li>
in wicket , the <li> is a WebMarkupContainer and <a> is a Link
when i am clicking a link , i want to change the li's class to active , and i'm doing this with a class made by me like in the following example :
Link link= new Link("link")
{
#Override
public void onClick() {
WMK.add(CssClassManagement.addAttribute("active"));
}
};
considering that WMK is the WebMarkupContainer containing the link .
Until here ,everything works , the problem is i can't figure out how i remove the class active from the <li> when another link is clicked ?
if your links point to different pages you can just check if the current page is one pointed by a given link and then decide to add or remove the active attribute.
The problem is in CssClassManagement.addAttribute("active").
This adds a permanent Behavior to the component that contributes "active" CSS class for each render of the component. If the Behavior is temporary (see Behavior#isTemporary()) then it will be used just once and removed immediately from the component. So next repaint of the page will not mark the link as active.
Another approach is to remove the CSS class when the click event happens:
$(function() {
$(document).on('click', 'a', function() {$('li.active').removeClass('active');});
});
This will remove the CSS class when the user clicks on an anchor. The repaint of the page will come with the new link selected as active.

Javascript code to kick off Spring WebFlow2 transition

Does anyone know of any javascript code that I can put on a radio button that will kick off a Spring WebFlow2 Transition event?
I am looking to kick off a transition to load values into a dropdown if the user clicks on a radio button... can someone please tell me if you seen this done.
In your situation I think you want to use Ajax to refresh only part of your page. What I use is a function in my global js file:
function ajaxWebFlowSubmitGet(divID,pars,view) {
new Ajax.Updater({success:divID},
view+"&date="+new Date().getTime(),
{ method:'get',
parameters:pars,
evalScripts:true,
onFailure:reportError,
requestHeaders: ['Accept','text/html;type=ajax']
});
}
which you can use then in your code with
ajaxWebFlowSubmitGet('dropdownListDiv','_eventId=eventID&fragments=dropDownFragment',${flowExecutionUrl});
just put that 'ajaxWebFlowSubmitGet' function in your page and call it from your radiobutton.
'dropdownListDiv' is the div you want to get updated
eventID is the name of the transition from your webflow you want to execute
dropDownFragment is the name of the fragment you want to receive as a response (and to be put in your 'dropdownListDiv')

update value of main window from a popup window

I'm trying to update the shopping cart quantity of the main window from a popup window.
How can I call the shopping cart controller from the popup before closing it and then display the result in main window?
I'm trying to call the spring controller using javascript.
window.opener is a reference back to the opening window. Here's some sample code:
win1.html:
pop up<br/>
set var
<div id="mydiv"></div>
win2.html:
<script>
window.opener.document.getElementById("mydiv").innerHTML = "test";
window.opener.myvar = "test2";
</script>
This is not an answer but more of a pointer. Oliver has given the right answer. If you are willing to experiment with new ways for achieving this you can try cross window messaging available in newer browsers. Here's a link to get you started
http://ejohn.org/blog/cross-window-messaging/

Howto set focus in Rich Faces panelBarItem?

Hi
I want to set focus on <h:inputText> element whenever rich:panelBarItem is opened.
I have:
<rich:panelBar>
<rich:panelBarItem onenter="setFocus();">
<h:inputText value="#{bean.value}"/>
</rich:panelBarItem>
</rich:panelBar>
it works fine when I open it with mouse click, but does not work first time when first panelBarItem is automatically opened.
How should I set focus on first opened panelBarItem? I really would like it to be some event(I could not find) on rich:panerBarItem or rich:panelBar.
You can call your method after page load to set focus to field. Something like
<script>
//call after page loaded
window.onload=setFocus();
</script>
or
<body onload="setFocus();">

Categories

Resources