I am developing jira and using variables in velocity, which are exposed as public getters in java plugin code. Everything seems good, I am getting my java code results in output.vm inside velocity template after processing excel file but I would like to add progressbar which is coded in pure javascript, so I have some js files and I would like to get velocity variables like current number of processed issue, and
how many issues are there to calculate progress. I can't bring solution because when
I am attaching <script> inside velocity .vm and alerting after timeouted function
the variable issueNumber is not changing at all, its 0. issueNumber is public instance variable in java.
<script>
function test() {
var get = $issueNumber;
alert(get);
}
setTimeout(test, 5000);
test();
</script>
My public variable issueNumber can be rendered in velocity as result after iterating in output velocity file, but can't be used as indicator in javascript where current progress is. Basically I need runtime variable not render time variable.
The velocity engine just replaces $issueNumber with the constant value during html page rendering and it happens only once so it is impossible to track any changes in that way. To achieve what you want you can implement an endpoint on the server-side which returns the actual state of the progress and do ajax calls to it in your script with some interval.
Related
I'm using the GWT Highcharts wrapper created by moxiegroup and want to add/change functionality to my project but also slowly move away from the moxiegroup wrapper as it uses JSNI and isn't maintained anymore. I am having trouble with importing Highcharts using Jsinterop in a way where i can use the JavaScriptObject as parameters for the Highcharts function.
What i want to do is use the native Highcharts function setTitle() to change the title of my already existing Chart object created by the wrapper. Before i have fixed this by passing the object as a JavaScriptObject to JSNI like in the following example:
private static native void nativeAddAxis(JavaScriptObject chart, JavaScriptObject axisOptions, boolean isX, boolean redraw, boolean animationFlag) /*-{
chart.addAxis(axisOptions, isX, redraw, animationFlag);
}-*/;
But when trying to do the same with Jsinterop the code wont compile because the native functions don't accept the JavaScriptObject type. I have tried casting it to the correct Js type and looking at other projects that use Jsinterop to wrap highcharts without any success.
Any help or suggestion on how to reach what i am trying to achieve without using JSNI is much appreciated. I must also add that i am very new to Js and far from a GWT guru.
Prior to the most recent SDK I was relying on the ability to access my sideInput inside of startBundle of my DoFn. I’m not sure of the history of refactoring but I seem to be having issues doing this now.
Essentially I have an array that I want to process across within my process() method and the array is reasonably sized that will fit in memory.
Is it valid to expect to access a sideInput within startBundle? And if so, how can I do that if startBundle is sent a Context instead of a ProcessContext?
Example:
#Override
public void startBundle(DoFn<KV<String, Iterable<String>>, String>.Context c) throws Exception {
uniqueIds = Lists.newArrayList(c.sideInput(iterableView));
super.startBundle(c);
}
The history is explained here: Why did #sideInput() method move from Context to ProcessContext in Dataflow beta
Do you need to do any processing on your side input to prepare it for use in processElement? If not, then I'd suggest just using View.asList() or View.asMap() and calling that directly in processElement() -- Dataflow will do caching when possible to make this cheap. (Note View.asList() is currently available on Github and will be in the next Maven release.)
If you need to do processing on your side input, and you are using the (default) GlobalWindow, then you can lazily initialize a local variable from within processElement(). However, if you are using Window.into(), you'll need to invalidate that cache every time the element's window changes.
I would like to know how can I build a clock (date and current time) using Dart. I'll be binding the resulting observable string (so it refreshes automatically) to an HTML Polymer element.
I thought about using a timer to refresh the string using DateTime.now(), but this seems to be a workaround, not the best solution.
I just need to know how to code the dart file, since the HTML and Polymer elements are already configured.
You might take a look at this example
https://github.com/bwu-dart/polymer_ui_elements/blob/master/example/polymer_ui_clock.html
https://github.com/bwu-dart/polymer_ui_elements/blob/master/lib/polymer_ui_clock/polymer_ui_clock.dart
It needs a little tweaking to work with the current Polymer version.
var oneSecond = new Duration(seconds: 1);
_timer = new Timer.periodic(oneSecond, updateTime);
updateTime is a method called every second.
I'm in the process of converting a classic ASP application to ASP.Net and have hit a brick wall to do with global variables (or page scope variables). As a note, the application is not a typical one in that it doesn't build HTML. Instead it gets AJAX requests and returns JSON strings, so as such doesn't use a lot of asp.net functionality. First time for a long time that googling hasn't lead me to an answer!
In the asp code we use a number of global variables defined in variables.asp, eg:
<%
dim lId
%>
This asp is then included in all pages. There are a number of other include files that reference these variables, along with the pages themselves.
For asp.net the closest I can find is to have variables.aspx:
<SCRIPT LANGUAGE="VBScript" RunAt="Server">
shared dim lId as integer
</SCRIPT>
However, I realise that this variable is much more 'global' than how it worked in .asp, and that it can cause threading issues etc, and that they effecitvely work like using the Application() object, which is not what I'm after.
Effectively what I need is to be able to declare a variable that can be referenced in other includes, and in the base page, whose scope/lifetime is only for the processing of that page.
At this stage, the only thing I can think of is to use Session variables, and to clear them at the end of each processing, but am dreading the work / issues of such a conversion
You could create a class in your asp.net project to store these static variables. If they are configuration parameters, they should go in the web.config file.
Looks like I might end up doing something like the following:
shared dim gv as New GlobalVariables
public class GlobalVariables
public property Id as integer
Get
Id = cint(HttpContext.Current.Items("id"))
End Get
set (ByVal aiValue as integer)
HttpContext.Current.Items("id") = aiValue
End Set
end property
end class
Then where ever I currently reference "lId", I need to replace with "gv.Id".
gv will still be global, but given it is looking in current.items I shouldn't have any thread issues.
I have an actionscript function that, after modifying some values and "executing" it, it has to return some specific result, my question is:
Is there a way to build a webpage that let users modify that function using a form and then execute it in order to get a result?
How do I "execute" actionscript functions? Thanks!
When you say modifying a function, do you want the user to create a function on the fly, and allow him to execute it?
Or you simply want to pass some arguments to an already existing function and then do some calculation and return the result?
Incase you simply want to execute a function within actionscript, from javascript, you can use ExternalInterface in ActionScript 3.0 , define a function and allow javascript to call that function.
public function functionToBeCalledFromJS(argument1,argument2)
{
Alert.show(argument1);
}
ExternalInterface.addCallBack('ASfunction',functionToBeCalledFromJS);
In JS when user submits a form call:
ASfunction(argument1,argument2);
Incase you want to return some data from AS to JS, then you need to call a JS function from within AS.
This can be easily accomplished using ExternalInterface.call();
Eg.
Lets say, you needed to do some calculation and then return the data
public function functionToBeCalledFromJS(argument1,argument2)
{
var returnInt:int = argument1+argument2;
}
ExternalInterface.call('JSFunction',returnInt);
IN JS:
function JSFunction(result)
{
alert(result);
}
For further details on this, you can go to http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#addCallback%28%29, which is the official site on AS3 reference.