Importing local classes in Haxe - class

I'm starting my first serious project in Haxe, but I've hit somewhat of a snag.
The problem is that if I try writing a class in a file other than my Main.hx, it is not being compiled. I've tried using import but that does not seem to work.
I'm using vim as a my ide with a few nice plugins(Youcompleteme, syntastic and vaxe) and the only haxelib is openfl.
Here is the boilerplate being created when I use the command openfl create project :
Project.xml
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta title="ProjetSession" package="com.sample.projetsession" version="1.0.0" company="Company Name" />
<app main="Main" path="Export" file="ProjetSession" />
<source path="Source" />
<haxelib name="openfl" />
<assets path="Assets" rename="assets" exclude="openfl.svg" />
<icon path="Assets/openfl.svg" />
</project>
ProjetSession.hxproj
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="CustomBuild" />
<movie input="" />
<movie path="project.xml" />
<movie fps="30" />
<movie width="800" />
<movie height="600" />
<movie version="1" />
<movie minorVersion="0" />
<movie platform="Lime" />
<movie background="#FFFFFF" />
<movie preferredSDK=";3;" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="D:\Development\Haxe\openfl" />
<class path="d:\Development\Haxe\lime" />
<class path="Source" />
<class path="Export\html5\haxe" />
</classpaths>
<!-- Build options -->
<build>
<option directives="openfl=3.0.0-beta
lime=2.1.3
tools=2.1.3
no-compilation
openfl-html5
canvas
lime-html5
html5
web
html5" />
<option flashStrict="False" />
<option noInlineOnDebug="False" />
<option mainClass="ApplicationMain" />
<option enabledebug="False" />
<option additional="--remap flash:openfl
--macro allowPackage("flash")" />
</build>
<!-- haxelib libraries -->
<haxelib>
<!-- example: <library name="..." /> -->
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<!-- example: <compile path="..." /> -->
</compileTargets>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<hidden path="obj" />
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand>"$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb</preBuildCommand>
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Custom" />
<option testMovieCommand="" />
</options>
<!-- Plugin storage -->
<storage />
</project>
The hml file is automatically generated by vaxe.

Defining a class and importing it, it is not sufficient to have that class compiled in your output. What you need is to actually "use" it. That can be accomplished by referring your class in your main function. To do that just use the class directly or use any other code that refer that class directly or indirectly.
This is a big advantage of the language that doesn't overload the output of your app with unneeded code. That also means that you can use third party libraries with confidence, knowing that only the bits of library you use will be embedded in your output.

Related

NLog not outputting anything to console

I'm following this tutorial
https://www.youtube.com/watch?v=jn6X-rx78ZU&list=PLJFgzBCcspK8p7Hxu2OLh-f-x0PBsIGjH&index=15&ab_channel=TheTutorialChef
and I'm trying to run the server at the end. NLog should output to console that server has started, but NLog is not outputting anything. I added the NLog config file below.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<target name="Console" xsi:type="Console" layout=" ${level} ${date} ${message} ${exception:innerFormat=Message,StackTrace}" />
<!-- https://github.com/NLog/NLog/wiki/ColoredConsole-target -->
<target name="CConsole" useDefaultRowHighlightingRules="true" xsi:type="ColoredConsole" layout="${logger} ${level} ${date} ${message} ${exception:innerFormat=Message,StackTrace}" >
</target>
<target name="warnfile" xsi:type="File" fileName="${basedir}/Logs/warning.txt"
maxArchiveFiles="4"
archiveAboveSize="10240"
archiveEvery="Day" />
<target name="infofile" xsi:type="File" fileName="${basedir}/Logs/info.txt"
maxArchiveFiles="4"
archiveAboveSize="10240"
archiveEvery="Day" />
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Info" maxlevel="Warn" writeTo="infofile" />
<logger name="*" minlevel="Warn" writeTo="warnfile" />
<logger name="*" minlevel="Trace" writeTo="CConsole" />
</rules>
</nlog>
But nothing outputs. There are no compilation errors or warnings. What have I done wrong? I'm using VSCode 2017, and NLog 4.7.6. I've tried editing the cofig file in the .nuget package directly. I've tried reinstalling NLog to get the original NLog.config, but now when I reinstall NLog, the config file doesn't appear in the root directory again.

How to configure Quartz.Net version 2.1.2.0 integrated with Log4Net

I have downloaded the newest version of Quartz.Net and try to configure it with common.logging and log4net dlls by using below configuration (based on this example)
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=2.1.2.400,Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4" />
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging, Version=2.1.2.0, Culture=neutral, PublicKeyToken=af08829b84f0328e" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="MyQuartzLog.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} – %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>
<quartz>
<add key="quartz.scheduler.instanceName" value="QuartzTestLog4Net" />
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="2" />
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
</quartz>
It does not work.
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=2.1.2.400,Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4" />
results in component loading error. I used sn.exe to check the publickeytoken. The keytoken is correct.
Removing the quartz sction can make the application run. But the log object has NoOpLogger information - {Common.Logging.Simple.NoOpLogger}.
My project refers to Common.Logging version 2.1.2.0; Common.Logging.Log4Net version 2.0.0.0; and log4net version 1.2.10.0. Are they right versions? If not, what are the right ones.
Thanks,
You should check the sample server that comes with Quartz.NET distribution.
https://github.com/quartznet/quartznet/tree/master/server/Quartz.Server
App.config:
It's type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"
NameValueSectionHandler is BCL type, not Quartz.NET's
You can probably leave out the version and public key
Package.config
You might have wrong packages. packages.config in sample contains working combination when using Log4Net 1.2.11

NAnt and System.Data.Entity.dll

I am new to NAnt and trying to set up a build file to build a few .Net 4.0 projects and run some NUnit tests. One of the projects contains an EF4.0 Data Model and context and I am running into an issue that even though the System.Data.Entity.dll reference is being included in the NAnt config, none of the System.Data classes contained in it are being found by the build (System.Data.EntityClient, System.Data.Objects, etc). I am using NAnt 0.91 Alpha 2. Anyone else run into this or have any idea how to get around it? Build file below.
Thanks.
<?xml version="1.0" encoding="utf-8" ?>
<project name="ClinicalModel">
<property name="src.dir" value="" />
<property name="output.dir" value="bin/debug" />
<property name="entitysrc" value="..\Entities" />
<property name="debug" value="true" overwrite="false" />
<property name="nant.settings.currentframework" value="net-4.0" />
<property name="framework-get-assembly-directory" value="${framework::get-assembly-directory('net-4.0')}" />
<property name="dotNetReferenceAssemblyPath" value="${framework-get-assembly-directory}\" />
<target name="clean" description="clean up already built files">
<delete file="${output.dir}/Entities.dll" failonerror="false" />
<delete file="${output.dir}/Model.dll" failonerror="false" />
</target>
<target name="build_entities" description="build entities">
<csc target="library" output="${output.dir}\Entities.dll" debug="${debug}">
<sources basedir="${entitysrc}">
<include name="**/*.cs" />
</sources>
</csc>
</target>
<target name="build" depends="build_entities" description="build model">
<csc target="library" output="${output.dir}\Model.dll" debug="${debug}">
<sources>
<include name="**\*.cs" />
</sources>
<references basedir="${output.dir}">
<include name="**\*.dll" />
</references>
</csc>
</target>
</project>
This may not be the solution you are looking for but I would recommend letting msbuild do the actual build work. Since you don't want to build the entire solution you would end up making 4 calls (one for each project you want to build) to msbuild. Here is a snippet from my root build script:
<property name="common.msbuild2010" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe" />
<property name="common.buildType" value="Debug" />
...
<setenv>
<variable name="DevEnvDir" value="C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\"/>
</setenv>
<exec program="${common.msbuild2010}" commandline=""${local.someCsProjName}" /t:Rebuild /p:Configuration=${common.buildType}" />

<f:propertyActionListener> tag not found

I cant seem to get to work. I am using icefaces and a very simple with two columns. One with actions such as remove and the other with a string (representing a regular expression). In order for the remove action to remove the right row, I am trying to link it to the actual element with an :
<html xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:m="http://www.mitre.org/asias/jsf">
<ui:composition>
<ice:dataTable binding="#{binding}"
value="#{binding.editableRows}"
var="item">
<ice:column>
<f:facet name="header">
<ice:commandLink styleClass="linkBlue"
action="#{binding.addEditableRow}">
<ice:outputText value="Add" />
</ice:commandLink>
</f:facet>
<ice:commandLink styleClass="linkBlue"
action="#{binding.removeEditableRow}">
<f:propertyActionListener value="#{item}" target="#{binding.actionRow}" />
<ice:outputText value="Remove" />
</ice:commandLink>
</ice:column>
<ice:column>
<f:facet name="header">
<ice:outputText value="Regular Expression" />
</f:facet>
<ice:inputText value="#{item.object}" size="100" />
</ice:column>
</ice:dataTable>
</ui:composition>
</html>
Everything I have found on this says that I need JSF 1.2. I am using JSF 1.2. Here is the apache Ivy config file I am using to manage my dependencies:
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org.mitre.asias" module="testwebproject" />
<configurations defaultconfmapping="default->default">
<conf name="default" visibility="public" description="needed for deployment" extends="runtime,master" />
<conf name="master" visibility="public" description="only this artifact" />
<conf name="runtime" visibility="public" description="libraries only needed at runtime" extends="compile" />
<conf name="provided" visibility="public" description="provided by container, not needed for deployment" />
<conf name="test" visibility="private" description="needed for testing" />
<conf name="compile" visibility="public" description="needed for compilation" />
<conf name="sources" visibility="public" description="the source artifact, if any."/>
<conf name="javadoc" visibility="public" description="the javadoc artifact, if any."/>
<conf name="optional" visibility="public" description="contains all optional dependencies"/>
<conf name="ide" visibility="public" description="all libraries, sources, and javadoc needed for ide" extends="master,compile,provided,test,sources,javadoc" />
</configurations>
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.4" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="log4j" name="log4j" rev="1.2.16" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.1" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="javax.el" name="el-api" rev="2.1.2-b05" conf="provided->compile(*),provided(*),runtime(*),master(*)" />
<dependency org="javax.servlet" name="servlet-api" rev="2.5" conf="provided->compile(*),provided(*),runtime(*),master(*)" />
<dependency org="javax.servlet" name="jsp-api" rev="2.0" conf="provided->compile(*),provided(*),runtime(*),master(*)" />
<dependency org="org.icefaces" name="icefaces" rev="1.8.2" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="org.icefaces" name="icefaces-comps" rev="1.8.2" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="org.icefaces" name="icefaces-facelets" rev="1.8.2" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="javax.faces" name="jsf-api" rev="1.2_13" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="javax.faces" name="jsf-impl" rev="1.2_13" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="com.sun.facelets" name="jsf-facelets" rev="1.1.14" conf="compile->compile(*),master(*);runtime->runtime(*)" />
<dependency org="junit" name="junit" rev="4.8.1" conf="test->default" />
<exclude module="servlet-api" conf="default" />
<exclude module="el-api" conf="default" />
<exclude module="jsp-api" conf="default" />
</dependencies>
</ivy-module>
I am using eclipse with IvyDE to manage that library and a Tomcat server instance running with "Use workspace metadata" selected. Is there some eclipse or tomcat thing that might be injecting the wrong version of JSF? When I look at the jsf-impl jar that is included by Ivy, I do see that there are com.sun.faces.taglib.jsf_core.SetPropertyActionListenerImpl and SetPropertyActionListenerTag in that jar. It is my understanding that those should be all that is needed. Any Ideas? Am I missing something, or just plain going crazy?
EDIT:
Now I'm getting really frustrated. Per the suggestion from BalusC I updated my faces-config.xml to use the 1.2 schema definition instead of the 1.1 dtd. This did not help. So I search around for more information. I find another stackoverflow article pertaining to (this issue), however there was no resolution other than getting a new version of jsf-facelets.jar (of which the new/old version is not listed). I am using the latest version available on repo1.maven.org/maven2 (1.1.14). So no go on that front. My new questions are, why would facelets have anything to do with this? Its a part of the JSF core is it not? I notice that in my jsf-impl-1.2_13.jar::META-INF/jsf_core.tld, there is a tag for setPropertyActionListener:
<tag>
...
<name>setPropertyActionListener</name>
<tag-class>com.sun.faces.taglib.jsf_core.SetPropertyActionListenerTag</tag-class>
<body-content>empty</body-content>
...
</tag>
On top of that, this can be found in my jsf-facelets-1.1.14.jar::com/sun/facelets/tag/jsf/core/CoreLibrary.java:
...
this.addTagHandler("setPropertyActionListener", SetPropertyActionListenerHandler.class);
...
It looks like my included libraries should be sufficient. Any idea what is going on here? Do I need to go back and get a degree in JSF to be able to write a simple facelet?
Ensure that the root declaration of your faces-config.xml is declared as per JSF 1.2 specification.
<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
Further, the binding="#{binding}" in your datatable really doesn't look right since #{binding} seems to be a managed bean.
I really hate to answer my own question, especially since it was such a simple mistake, but sometimes we just have to fess up and accept the public humiliation. Anyway, long story short, its:
<f:setPropertyActionListener value="#{item}" target="#{binding.actionRow}" />
not
<f:propertyActionListener value="#{item}" target="#{binding.actionRow}" />
Hopefully, this will help someone else in the future...

GWT hosted mode not working with Spring + Eclipse + GWT Eclipse plugin

I've been trying to get GWT working with Spring for a while now. Is there anyone who is using official Eclipse GWT plugin with Spring, and who has managed to get hosted mode working with that combination?
I'm using GWTController to initialize GWT through dispatcher-servlet.xml. Since my WEB-INF is not in war, but in WebContent folder, I use "-war WebContent" switch when compiling Java code to .js.
As for hosted mode... if I try to run it through IDE (Run as Web Application) I get "Launch failed - Could not find any host pages in project MyProject." I tried running it with Ant task which goes something like this:
<condition property="XstartOnFirstThread" value="-XstartOnFirstThread">
<os family="mac"/>
</condition>
<condition property="XstartOnFirstThread" value="">
<not><os family="mac"/></not>
</condition>
<target name="hosted" depends="" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode">
<classpath>
<pathelement location="src" />
<path refid="my-client-classpath" />
</classpath>
<jvmarg value="-Xmx256M" />
<jvmarg line="${XstartOnFirstThread}" />
<arg value="-startupUrl" />
<arg value="MyPage.html" />
<arg value="my.gwt.client.Whatever" />
</java>
</target>
This results in hosted mode starting, but I get 404 instead of my web page...
EDIT: When I go to hosted mode, I see folder with compiled Javascript code but nothing else. So my question is basically has someone got a good tutorial or a setup he can share? There is a lot of half-baked info on the Net, but I wasn't able to make any of it work.
EDIT 2: Here's my .gwt.xml file, it's pretty basic:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='whatever'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='my.gwt.client.Whatever' />
<!-- Lokalizacije -->
<extend-property name="locale" values="hr" />
</module>
We used this tutorial to get it working for us, hope it helps