My question is not so hard, i think. But it does not change the fact that i dont know how to do it :) Anyway, how can i use yui calendar object in my wicket page? i have tried some codes in java codes, but i got some errors, so i need your precious help. Thanks.
Its is as simple as this:
...
import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.extensions.yui.calendar.DatePicker;
...
DateTextField df = new DateTextField('wicketID', dateModel, "yy.DD.mm");
df.add(new DatePicker());
form.add(df);
Basicaly, you construct a normal DateTextField and add the YUI Picker to it. thats about all.
enjoy
Edit: to answer the questions in the comments:
user500129: are you using maven as build tool? i strongly suggest it to you. if you do, you find the yoi components in the wicket-datetime artefact. The relevant maven dependency is:
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-extensions</artifactId>
<version>${wicket.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
If you are not using maven, you can download the jar from the maven repository, for wicket.14.14 this would be the correct link: http://mvnrepository.com/artifact/org.apache.wicket/wicket-datetime/1.4.14
hope that helps
Related
I'm trying to implement code from https://github.com/sstrickx/yahoofinance-api on Eclipse in Java. When I run the program, I'm getting a several lines of errors that are being printed on the console. When I click on the errors, it takes me to a window named "YahooFinance.class" on Eclipse that says "Source not found." It asks me to change the attached source. I have added the source to C:/Program Files/Java/jdk-11.0.11/lib/src.zip on my computer, but I'm still getting the same error. Any help would be greatly appreciated!
[Screenshot of error][1]
[1]: https://i.stack.imgur.com/GZuL7.png
Edit:
This is the code that I am trying to compile from source:
Stock stock = YahooFinance.get("INTC");
BigDecimal price = stock.getQuote().getPrice();
BigDecimal change = stock.getQuote().getChangeInPercent();
BigDecimal peg = stock.getStats().getPeg();
BigDecimal dividend = stock.getDividend().getAnnualYieldPercent();
stock.print();
My project is Maven-based and I have added this dependency to the pom.xml file:
<dependency>
<groupId>com.yahoofinance-api</groupId>
<artifactId>YahooFinanceAPI</artifactId>
<version>3.15.0</version>
</dependency>
After refreshing my project's Maven dependencies, like Kevin Hooke said to do, I am no longer getting the "Source not found" error. Thank all of you for your quick responses and help!
The source project you're trying to use is a Maven based project and provides instructions on how to include it as a dependency.
Create a new Maven project in Eclipse (or update your project to be Maven based, adding a pom.xml file, standard folder structures etc)
Edit your pom.xml file and add a dependency to the yahoofinance-api project:
<dependency>
<groupId>com.yahoofinance-api</groupId>
<artifactId>YahooFinanceAPI</artifactId>
<version>x.y.z</version>
</dependency>
Replace x.y.z with the version that you need to use
Refresh your project's Maven dependencies: right-click project, Maven -> Update Project
I have a project that I'm trying to play around with the Immutables Criteria: https://immutables.github.io/criteria.html
I added the following to my pom.xml:
<dependency>
<groupId>org.immutables</groupId>
<artifactId>criteria-inmemory</artifactId>
<version>2.8.2</version>
</dependency>
Everything seemed fine. However, I am having some issues getting things imported and working. I have no issues with Immutables.Value that works fine. When I import Criteria Eclipse complains about:
The type org.immutables.criteria.Criteria is not accessible
So I tried adding the module to my module-info.java as follows:
requires org.immutables.criteria-common;
Also tried:
requires org.immutables.criteria-inmemory;
I'm using Eclipse suggestions to auto-complete the module name because I don't really know what the module name should be but, when I add the above Eclipse says there is a syntax error with the "-" in the requires statement. So at this point I am kinda stuck! If anyone has any suggestions I would love to hear them!
Thanks!!
I was able to track down the issue with the Immutables Library and I posted the following issue: https://github.com/immutables/immutables/issues/1223
Basically, the library was creating an invalid Automatic-Module-Name tag in there pom.xml's when building the jar files. The values that we being set contained a "-" which is invalid.
Shoutout to #Naman for pointing me in the right direction! Thanks!
I am still wondering if it is possible to override the jar files module-name. It seems like it could be useful for users of a library to somehow override a libraries jar files module-name for situations like this.
I'm looking to implement a pre-commit automatic formatter for my team because the code is a bit all over the place. I like spotless and the google style but a sticking point seems to be 4-space indents, whereas it's currently outputting 2-space indents.
Is there a way to override this value via pom.xml, either on spotless side or the google side?
As instructed in Github issue comments here: https://github.com/diffplug/spotless/issues/420
You can solve this in Gradle build with:
indentWithTabs(2)
indentWithSpaces(4)
For Maven the same code would be:
<java>
<googleJavaFormat>
<version>1.8</version>
<style>GOOGLE</style>
</googleJavaFormat>
<indent>
<tabs>true</tabs>
<spacesPerTab>2</spacesPerTab>
</indent>
<indent>
<spaces>true</spaces>
<spacesPerTab>4</spacesPerTab>
</indent>
</java>
Google java format is not configurable by design: https://github.com/google/google-java-format/pull/57#issuecomment-233450426
There is no configurability as to the formatter's algorithm for formatting. This is a deliberate design decision to unify our code formatting on a single format.
Also see: https://github.com/google/google-java-format/wiki/FAQ#i-just-need-to-configure-it-a-bit-differently-how
A quick update: the spotless plugin can now be configured to do what you want. I.e. google-java-format with 4 spaces.
As mentioned in the docs: https://github.com/diffplug/spotless/tree/main/plugin-maven
you can now use the AOSP 'style' which does what you need.
<googleJavaFormat>
<version>1.8</version>
<style>AOSP</style>
</googleJavaFormat>
Similar to the other answer, I tried to indent with Tabs(1) and Spaces(2). It also worked.
spotless {
java {
googleJavaFormat("1.7")
indentWithTabs(1)
indentWithSpaces(2)
}
}
I've added following into dependencies section of my pom.xml:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4.1</version>
<scope>test</scope>
</dependency>
But when I add the 1st line of "Quick start guide" (http://hc.apache.org/httpcomponents-client-4.4.x/quickstart.html):
CloseableHttpClient httpclient = HttpClients.createDefault();
IntelliJ IDEA highlights "HttpClients" and tells me:
Cannot resolve symbol 'HttpClients'
It looks like I have mistake with configuration. What exactly is wrong? please advise how to add support for HttpClients into the project?
Thanks!
P.S. Learned a bit more, looks like "" is redundant and wrong for this case, I removed it but that didn't help: still non-compilable.
EDIT: If I put cursor to 'HttpClients' and hit "Alt-enter" the pop-up doesn't contain any class to import. See screenshot:
It looks like my IntelliJ had issues with caching, cleaning cache with following re-importing of the project helped.
I found tips on that here: IntelliJ inspection gives "Cannot resolve symbol" but still compiles code
P.S. Though few other project were broken as a result of this action. Looks like I need to keep learning :)
Download the jar file from
https://jar-download.com/artifacts/org.apache.httpcomponents/httpclient/4.5.6/source-code
Extract the .jar file name httpclient-4.5.6.jar. Form a directry name lib under your project and import this .jar file to it. Right click your .jar file and click addtolibrary.
java Source code not compiling with jdk 6.
import org.w3c.dom.Node;
Node node = list.item(0);
String txtContent = node.getTextContent();
getTextContent() not found in the jdk 6
how can solve this compilation issue.
I came here with the same problem. Even worse: I had two projects side by side, both targetting the same JRE (1.6), and one was able to resolve Node.getTextContent() while the other wasn't. I resolved it sort of by accident; I went to project properties | Java Build Path | Order and Export tab, selected the JRE (which was at the bottom of the list) and clicked the "Top" button to move it to the top. My problem went away. It appears that the Node I wanted was hidden by another one. :-\ Maybe this will help with your problem.
Although a late post... maybe someone will find this useful.
I didn't like the manual project setting with JRE on top because all my colleagues would have to go trough this every time the project was imported, so I found another solution.
In my case I had the following dependency tree: org.reflections (0.9.8) -> dom4j (1.6.1) -> xml-apis (1.0.b2).
In order to fix it, I added an exclusion in the org.reflections dependency, like this:
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.8</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
In your case maybe there is another dependency that imports a faulty jar. E.g.: Dealing with "Xerces hell" in Java/Maven?
Please check http://www.jarfinder.com/index.php/java/info/org.w3c.dom.Node to see all the jars that contain that class.
I have also faced the similar problem. It is nothing to do with the Source Code. Steps to solve the problem is,
Go to project Properties (Right click on project and choose properties)
Select Java Build Path
Go to Order and Export tab
Make sure your JRE library is on TOP. If it is not in top, make it to top.
Click on OK and see after completing the build progress in right down.
For anyone working with hibernate the solution is similar to virussu_ro above.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
Possibly a long shot, but are you sure you're using JDK 6? Sometimes IDEs like Eclipse have a dropdown in the Project window that lets you choose a version, and it may be set to 1.4. Or you may have your CLASSPATH set incorrectly. Worth checking if you have ever had Java 1.4 installed.
I ask because Node.getTextContent was added in JDK 1.5, so the only way I can explain its absence is that you are using the Java 1.4 version of org.w3c.dom.Node.
Try running this code to determine location of jar:
System.out.println(System.getProperty("java.version"));
ProtectionDomain domain = org.w3c.dom.Node.class.getProtectionDomain();
System.out.println("domain: " + domain);
CodeSource codeSource = domain.getCodeSource();
if(codeSource != null) {
System.out.println("location: " + codeSource.getLocation());
} else {
System.out.println("null location, probably JRE class");
}
Maybe there is a jar on classpath that contains org.w3c.dom.Node class and hides the correct one.