application-context.xml problem for Spring ActionScript - actionscript-3

content of The application-content.xml is
<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.springactionscript.org/schema/objects"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springactionscript.org/schema/objects
http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd">
<property file="strings.properties" />
<object id="string1" class="String"/>
<object id="string2" class="String"/>
<object id="nlslzf" class="com.sgb.model.MyClass"/>
</objects>
content of strings.properties is:
s1=Firststring
s2=Secondstring
but error:
Main Thread (Suspended: Error: An object definition for 'string1' was not found.)
org.springextensions.actionscript.ioc.factory.support::AbstractObjectFactory/getObject
SpringActionScript/test
SpringActionScript/onCreationComplete
SpringActionScript/___SpringActionScript_Application1_creationComplete
flash.events::EventDispatcher/dispatchEventFunction [no source]
mx.core::UIComponent/dispatchEvent
mx.core::UIComponent/set initialized
mx.managers::LayoutManager/doPhasedInstantiation
Function/http://adobe.com/AS3/2006/builtin::apply [no source]
mx.core::UIComponent/callLaterDispatcher2
mx.core::UIComponent/callLaterDispatcher2
mx.core::UIComponent/callLaterDispatcher
i can run normal if removed the ''
why it is? springactionscript bug?

This does indeed 'smell' like a Spring Actionscript bug.
Please file a bug report for this in our JIRA system:
SpringAS JIRA
If you can, add a sample project that demonstrates the bug, that way we'll be able to track down the issue easier and faster.

Related

How to map home url (/)

I have successfully deployed my .WAR file to openshift.com.
In order to access my website, I have to type this url: http://demo-farazdurrani.rhcloud.com/main
You see that after ".com" I have to type "/main". When I only type the website name without '/main', it throws '404 resource not found' error. I just want to be able to just type http://demo-farazdurrani.rhcloud.com/ (or better yet remove that '/' too) and it should automatically open my main home page.
This is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
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-app_3_0.xsd"
metadata-complete="false">
<display-name>Advanced Mappings Demo Application</display-name>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.jspf</url-pattern>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/WEB-INF/jsp/base.jspf</include-prelude>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
<default-content-type>text/html</default-content-type>
</jsp-property-group>
</jsp-config>
<session-config>
<session-timeout>30</session-timeout>
<cookie-config>
<http-only>true</http-only>
</cookie-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
And this is my onStartUp method (I configured it programmatically):
#Override
public void onStartup(ServletContext container) throws ServletException
{
AnnotationConfigWebApplicationContext rootContext =
new AnnotationConfigWebApplicationContext();
rootContext.register(RootContextConfiguration.class);
container.addListener(new ContextLoaderListener(rootContext));
AnnotationConfigWebApplicationContext servletContext =
new AnnotationConfigWebApplicationContext();
servletContext.register(WebServletContextConfiguration.class);
ServletRegistration.Dynamic dispatcher = container.addServlet(
"springDispatcher", new DispatcherServlet(servletContext)
);
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
container.getServletRegistration("default").addMapping("/resources/*", "*.css", "*.js", "*.png", "*.gif", "*.jpg");
}
Any help is appreciated. Thanks
with spring applications usually what is suggested is to use a rewriter of url like:
in your web.xml
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>yourservlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>yourservlet</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
by default will read a urlrewrite.xml in your WEB-INF directory you'd have something similar to:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite
PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
"http://tuckey.org/res/dtds/urlrewrite3.0.dtd">
<urlrewrite default-match-type="wildcard">
<rule>
<from>/resources/**</from>
<to>/resources/$1</to>
</rule>
<rule>
<from>/spring_security_login</from>
<to last="true">/spring_security_login</to>
</rule>
<rule>
<from>/j_spring_security_check**</from>
<to last="true">/j_spring_security_check/$1</to>
</rule>
<rule>
<from>/j_spring_security_logout**</from>
<to last="true">/j_spring_security_logout/$1</to>
</rule>
<rule>
<from>/**</from>
<to>/app/$1</to>
</rule>
<outbound-rule>
<from>/app/**</from>
<to>/$1</to>
</outbound-rule>
</urlrewrite>
that should be enough, I use this very same configuration for a deployment in openshift! and works the way you want
Okay now I know how to do it. First step is this: https://stackoverflow.com/a/23981486/4828463 Although rename my .war file to ROOT.war was important, I was missing one important .jsp file at a important location (now this solution is particular to my problem. It is possible that it could be helpful to you as well). I added "index.jsp" at the root of my web application. And Inside it I have
<%# page session="false" %>
<c:redirect url="/main" />
The main thing that's needed here is the 2nd line. It will redirect all the calls to http://app-domain.rhcloud.com/ to http://app-domain.rhcloud.com/main, which I actually need. I just type http://demo-farazdurrani.rhcloud.com/ and it redirects it to http://demo-farazdurrani.rhcloud.com/main
First line is optional (not needed for my solution) and is doing this: It is needed page that doesn't need to be involved in a session. Or if this code is specified in a JSP page, it means session objects will not be available for that page. Hence session cannot be maintained for that page. (just putting it out there not neccassary for my question though).
I will show you how my project structure looks like now:
Earlier in the question I was asking if I need to change anything in web.xml. No I don't. Everything is fine there.
upvote the question and answer if you found this helpful. Thanks

quickbooks online recievepaymentadd

i am trying to add a payment to quickbooks online from my web app. This is the xml that i am sending:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="6.0"?>
<QBXML>
<SignonMsgsRq>
<SignonTicketRq>
<ClientDateTime>2013-05-09T01:37:58</ClientDateTime>
<SessionTicket>V1-115-Q04ffswegvh9uzxaw8qrud:689712285</SessionTicket>
<Language>English</Language>
<AppID>688664435</AppID>
<AppVer>1</AppVer>
</SignonTicketRq>
</SignonMsgsRq>
<QBXMLMsgsRq onError="stopOnError">
<ReceivePaymentAddRq>
<ReceivePaymentAdd defMacro="MACROTYPE"> <!-- required -->
<CustomerRef> <!-- required -->
<ListID >5</ListID> <!-- optional -->
</CustomerRef>
<ARAccountRef>
<FullName>Accounts Receivable:Customer Receivables</FullName>
</ARAccountRef>
<AppliedToTxnAdd> <!-- optional, may repeat -->
<TxnID useMacro="MACROTYPE" >143</TxnID> <!-- required -->
</AppliedToTxnAdd>
<TxnDate >2013-05-09</TxnDate>
<RefNumber >123</RefNumber>
</ReceivePaymentAdd>
</ReceivePaymentAddRq>
</QBXMLMsgsRq>
</QBXML>
I get an error saying:
SAX parser encountered an error parsing request file.
Exception from other package:
org.xml.sax.SAXParseException: The content of element type "ReceivePaymentAdd" must match "(CustomerRef,ARAccountRef?,TxnDate?,RefNumber?,TotalAmount?,PaymentMethodRef?,Memo?,DepositToAccountRef?,CreditCardTxnInfo?,(IsAutoApply|AppliedToTxnAdd+)
I just need to apply a payment to an invoice. The payment will always be for the full amount of the invoice.
Any ideas what is wrong?
Thanks Randy
The order of tags in qbXML matters.
So if the Intuit OSR reference shows you that the correct order of tags is:
<CustomerRef>
<ListID>IDTYPE</ListID>
</CustomerRef>
<ARAccountRef>
<FullName>STRTYPE</FullName>
</ARAccountRef>
<TxnDate>DATETYPE</TxnDate>
<RefNumber>STRTYPE</RefNumber>
...
<AppliedToTxnAdd> ...
And you instead send tags in this order:
<CustomerRef>
<ListID >5</ListID>
</CustomerRef>
<ARAccountRef>
<FullName>Accounts Receivable:Customer Receivables</FullName>
</ARAccountRef>
<AppliedToTxnAdd>
<TxnID useMacro="MACROTYPE" >143</TxnID>
</AppliedToTxnAdd>
<TxnDate >2013-05-09</TxnDate>
<RefNumber >123</RefNumber>
Then you're going to get errors.
(notice you have TxnDate and RefNumber after the AppliedToTxnAdd tag, when the spec defines it as coming before the AppliedToTxnAdd tag)
What it's trying to tell you here:
The content of element type "ReceivePaymentAdd" must match
"(CustomerRef,ARAccountRef?,TxnDate?,RefNumber?,TotalAmount?,PaymentMethodRef?,Memo?,DepositToAccountRef?,CreditCardTxnInfo?,(IsAutoApply|AppliedToTxnAdd+)
Is that it's expecting tags in that order, and you sent them in a different order than it expected.
If you fix the order of the tags, it will work.
We have some example qbXML requests on our QuickBooks integration wiki guide if that helps.

How do I get autocompletion for Flex Metadata?

I took a look at flex metadata and it seems to be quiet straight forward. Though I have a problem, I don't get autocompletion for the metadata.
I'll tell you what I did, maybe you find an error. I want to create my own Style metadata tag named e.g. MyStyle. I want to create my own because it's easier for me to determine at runtime if the metadata was added by me or by the flex framework (therefore I will not use the predefined Style metadata tag).
To add metadata is pretty simple, I just wrote this code to get it work:
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
width="1024" height="768">
<fx:Metadata>
[MyStyle(required="true")]
</fx:Metadata>
</s:Group>
On my WindowedApplication component I added an added to stage listener to the stage. So all elements that are added to the application will fire that Event.ADDED when they are added to the stage. In that eventHandler I scan added elements for my metadata tag.
protected function addedToStageListener(event:Event):void
{
var classInfo:XML = describeType(event.target);
for each (var x:XML in classInfo..metadata)
{
if (x.#name == "MyStyle")
trace(x);
}
}
I also added a flex-config.xml file (in the toplevel of my src folder) to add the compiler options, so that I can read my custom metadata tag on runtime. The file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<flex-config>
<compiler>
<keep-as3-metadata>
<name>MyStyle</name>
</keep-as3-metadata>
</compiler>
</flex-config>
When I run this, I get the result I expect
<metadata name="MyStyle">
<arg key="required" value="true"/>
</metadata>
So this works. My next step was to add autocompletion when adding the metadata tag to the code. To do this you should create a metadata.xml which specifies the metadata tags right?
So I did this and I ended up with this simple metadata.xml
<?xml version="1.0" encoding="UTF-8"?>
<annotations version="2.1.1">
<metadata name="MyStyle" description="Adds style.">
<context name="class" />
<attribute name="required" type="Boolean" required="true" />
</metadata>
</annotations>
To add the metadata.xml correctly to the project I followed that tutorial by Adobe, but it doesn't work. I don't get autocompletion. Do you have any suggestions?
Update: I use Flash Builder 4.6 Professional and I created a Flex Library Project.

Flex - ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller when using added swc file

I know already so many questions have been asked here on this error #2025 topic.
But, in my case, it is happening when trying to use a .swc file in a flex project.
I am trying to use one of my library project into another flex project by adding using "Add swc" file.
I have successfully added it in my new project as a .swc file.
But, when I try to use it new project by clicking on the application in browser, it shows me this runtime error. Below is my new project's main file.
NewSample.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:swclib="*"
layout="absolute">
<swclib:Main width="100%" height="100%"/>
</mx:Application>
StackTrace:
ArgumentError: Error #2025: The supplied DisplayObject must be a child
of the caller. at
flash.display::DisplayObjectContainer/getChildIndex() at
mx.managers::SystemManager/getChildIndex()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:1772]
at
mx.managers::SystemManager/mouseDownHandler()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:3615]
I am unable to identify what caused the error ?
EDIT : This is the main application file of the .swc library file.
Main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:parsley="http://www.spicefactory.org/parsley"
minWidth="955" minHeight="600"
xmlns:custom="components.*"
horizontalScrollPolicy="off"
layout="vertical"
verticalScrollPolicy="off" xmlns:models="models.*" xmlns:views="views.*">
<views:Header width="100%" height="50"/>
<mx:HDividedBox id="hdv" width="100%" height="100%">
<views:ABC width="15%" height="100%"/>
<views:DEF width="65%" height="100%"/>
<views:XYZ width="20%" height="100%"/>
</mx:HDividedBox>
<parsley:ContextBuilder config="Conf"/>
</mx:Application>
Do you really need Application? Application should be only the upper one and main class.
Possible solutions:
Use another container (for example Canvas).
Compile your Main.mxml application into swf and then load it with Loader class.
I'd prefer to use 1st variant.
I bet you are not checking if the (you think child) object is actually a child of the (you think parent) object
Put an if there like:
if(parentObj.getChildren().indexOf(childObj) >= 0) {
parentObj.removeChild(childObj);
} else {
//whatever error logging you do goes here
}

getting Deep into Flex

The better you understand what you are doing, the better you will do it.
I want to get Deep into Flex . I did some simple Event-Handling and
The better you understand what you are doing, the better you will do it.
But i have i big question:
What does the Compiler do ?!
What happens with the MXML file ?
lets say we have a simple code ( code from blogflexexamples):
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/27/changing-the-flex-colorpicker-controls-swatch-panel-background-color/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="top"
backgroundColor="white">
<mx:Style>
.myColorPicker {
swatchPanelStyleName: myCustomSwatchPanelStyleName;
}
.myCustomSwatchPanelStyleName {
backgroundColor: haloBlue;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.events.ColorPickerEvent;
private function backgroundColor_change(evt:ColorPickerEvent):void {
var cssObj:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".myCustomSwatchPanelStyleName");
cssObj.setStyle("backgroundColor", evt.color);
colorPicker.open();
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:Form styleName="plain">
<mx:FormItem label="backgroundColor:">
<mx:ColorPicker change="backgroundColor_change(event);" />
</mx:FormItem>
</mx:Form>
</mx:ApplicationControlBar>
<mx:ColorPicker id="colorPicker"
styleName="myColorPicker"
editable="false" />
</mx:Application>
does this generate an Actionscript file ?
and if it does : Can i see the the .as file ( like preprocessor in C++ )?
Yes. MXML is translated into an ActionScript class. You can see the generated as code by adding -keep-generated-actionscript switch to the Additional compiler arguments in Project properties->Flex compiler.
Another good reference is the recently-released book Developing Flex 4 Components by Mike Jones. It mentions the compilation of MXML to Actionscript on page 4 and provides a solid grounding in how Flex components work.
For reference, here are some good places to digg deep into the Flex Compiler:
Diving in the Data Binding Waters (with Presentation Slides) - Shows how [Bindable] is converted into actionscript
Flex SDK Compiler Source Code
Flex 3 Compiler Design
Flex Mojos (with Source SVN) - Awesome code customizing how the compiler processes things.
Clement Wong's Blog - He was the previous leading Flex Compiler Engineer, points to some good resources.
Customizing Metadata Processing with Flex 4 Custom Compiler Extensions - New resources for the Compiler