Struts s:autocompleter tag onchange event - struts2

Is there a way to add an onchange event to the s:autocompleter tag in struts?
I need to call a javascript function when the selection changes.

Related

How to communicate between mvc partial view and angular component

How can i call a method inside the angular component when i change the drop down in the partial view.
I have a Partial view with a drop down control and an angular component in my mvc page. When i change my drop down in the partial view(created using razor engine), i need to trigger a method inside the angular component.
I found a workaround.
Add a input on the angular component html
<input type="hidden" id="selDate"/>
attach an onChange event in the corresponding .ts file
$(function () {
$('#selDate').on('change', function () {
var dt = $('#selDate').val();
self.getIRData(dt);
});
});
set the value of the above control from the partial view(dropdown change event) and simulate an onChange event by adding Dispatchevent()
please let me know if you have any better workarounds

JQuery mobile bind event for single page model

Sorry to ask such a basic question on JQuery mobile, but I am not so clear.
With a single page model (split an app into multiple pages), all scripts are loaded at the landing page. However, UI elements (e.g. buttons) may not appear until several pages deep into the clicks. Where and how do I bind event that are not yet loaded? Or how do I bind event as the pages are loaded? $(document).bind("pagecreate", function(){}) is just going to run on landing page, but I suppose I need to bind after the widgets have appeared.
I bind it like this:
$(document).bind("pagecreate", function(event, data) {
$('#btn_newuser2').on('vclick', function(event) {
// do something here.
});
});
You are safe binding event handlers for all DOM elements in the pagecreate event, if you use delegation:
$(document).on("click", "#my_button", function()
{
// handler
});
In this example the click event is binded to the whole document, but the second parameter is a selector for a child element. As stated in the docs:
Event delegation allows us to attach a single event listener, to a parent element, that will fire for all descendants matching a selector, whether those descendants exist now or are added in the future

I want to call an action class onChange of select tag in struts2

I want to call an action class on change of select tag in struts2 without refreshing the form. please guide me. what i am doing. I call a javascript function onChange event where i set the name of action in the form's action attribute and then i call submit of the form.

Getting the value of Primefaces' p:editor when onchange is called

I have a component.
I want to be notified whenever its value is changed. Then I need to check the new value to decide if it's empty (hence, I'll disable the submit button) or not.
The former can be done using the onchange attribute.
My problem is with the latter: accessing p:editor's value from within javascript!
Please help.
I found the solution.
Here is the p:editor with the onchange attribute:
<p:editor onchange="handleTextChange()" id="responseEditor"/>
and here is the Javascript callback function:
function handleTextChange()
{
editorText = document.getElementById("appDetailsForm:responseEditor_input").value;
alert(editorText);
}
p.s.1 appDetailsForm is the id of the enclosing form. Primefaces prepends it to the component's primfaces Id when it generate the html.
p.s.2 appDetailsForm:responseEditor_input is the id of the textarea inside the <p:editor> component that is created when the html is generated.

I want to Dynamically Create Select list when i click a button by using struts2 tag?

I want to Dynamically Create Drop down list when i click a Button and the value selected in the Drop Down List should be inserted into the Database The Drop Down List should be in Struts2 Tag.
function addDropDown(parent){
var myselect = document.createElement("select");
myselect.setAttribute("name","someName");
myselect.onchange=function(){ submitvalue(this.value) };
theOption=document.createElement("OPTION");
theText=document.createTextNode("text gere1");
theOption.appendChild(theText);
theOption.setAttribute("value","value here1");
myselect.appendChild(theOption);
theOption=document.createElement("OPTION");
theText=document.createTextNode("text gere2");
theOption.appendChild(theText);
theOption.setAttribute("value","value gere2");
myselect.appendChild(theOption);
theOption=document.createElement("OPTION");
theText=document.createTextNode("text gere3");
theOption.appendChild(theText);
theOption.setAttribute("value","value gere3");
myselect.appendChild(theOption);
parent,appendChild(myselect);
}
call this function onClick of your button with some parent element(form or div) as argument.The function submitvalue() will be called on selection of any element of the dropdown, do your database submit action there(submit using ajax or whatever you are using as you have not mentioned it). I also noticed you have mentioned that the dropdown should be in struts2 tags, icouldnt wonder why as even the static struts2 tags get changed to html tags when executed

Resources