Here's a capacitor plugin I found https://github.com/JhonArlex/capacitor_qrcode
and I want it to integrate it to my ionic app, on web serve it works as expected, but when I try on livereload on android, the error screen pops out and says the plugin is undefined..
import "capacitor_qrcode";
import { Plugins } from "#capacitor/core";
//..
await Plugins.QRCodePlugin.getCodeQR();
// QRCodePlugin is undefined?
I'm using Ionic React Capacitor... also would appreciate if you can suggest any other way I could integrate QR code scanning feature on my app thanks!
When using your own plugins you need to register/add it into your android MainActivity.
https://capacitor.ionicframework.com/docs/plugins/android#export-to-capacitor
Like this:
import com.jhon.capacitor_qrcode.QRCodePlugin;
public class MainActivity extends BridgeActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(QRCodePlugin.class);
}});
}
}
Related
public class BackendVerticle extends AbstractVerticle {
#Override
public void start() throws Exception {
// tag::backend[]
Router router = Router.router(vertx);
router.get().handler(StaticHandler.create()); // <3>
vertx.createHttpServer()
.requestHandler(router)
.listen(8080);
// end::backend[]
}
// tag::main[]
public static void main(String[] args) {
Vertx vertx = Vertx.vertx(); // <1>
vertx.deployVerticle(new BackendVerticle()); // <2>
}
// end::main[]
}
I have created react application with vertex following https://how-to.vertx.io/single-page-react-vertx-howto/. I have set react routing using react-router which works fine when i use the internal react node server which runs on localhost:3000 by default.But when i trid to serve static pages via vertx static handler except for default / route other routes return "Not Found"
enter image description here
When the static website is built, it consists in a single index HTML file.
The React Router allows to create paths for specific views. These paths can be interpreted by the React Router but they do not map to actual files on the backend server.
This is why you get a 404 NOT FOUND response if you try to load anything else than /.
To fix the issue, configure the Vert.x Web Router to reroute anything the StaticHandler could not load to /:
// After you've setup the other routes
router.get().handler(StaticHandler.create());
router.get().handler(rc -> rerouteToIndex(rc));
private void rerouteToIndex(RoutingContext rc) {
if (!"/".equals(rc.normalisedPath())) {
rc.reroute("/");
} else {
rc.next();
}
}
I understand that JavaFX's Alert cannot be used yet with mobile apps. But what about the Gluon Charm Alert?
I have defined a Gluon Mobile MultiView FXML project. I've updated the gradle project's dependencies to include charm-2.2.0.jar, so the Gluon Charm Alert class is available. In order to use it, you also need access to javafx.scene.control.Alert.AlertType.
I don't seem to have compile-time access to the above AlertType class.
I'm using NetBeans 8.1 with the most recent Gluon/Gradle plug-in on a Mac with OS X 10.11.14. Is there an additional configuation dependency I must define?
Thanks in advance for any help.
Here is my build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.capitals.Capitals'
dependencies {
compile 'com.gluonhq:charm:2.2.0'
androidRuntime 'com.gluonhq:charm-android:2.2.0'
iosRuntime 'com.gluonhq:charm-ios:2.2.0'
desktopRuntime 'com.gluonhq:charm-desktop:2.2.0'
}
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.asgteach.capitals.**.*',
'com.gluonhq.**.*',
'io.datafx.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
You can access JavaFX Alert.AlertType class, without the need of adding any dependency.
Make sure you are using the latest version of the jfxmobile plugin (1.0.8).
This works on desktop and mobile:
import com.gluonhq.charm.glisten.control.Alert;
import com.gluonhq.charm.glisten.control.AppBar;
import com.gluonhq.charm.glisten.mvc.View;
import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
public class BasicView extends View {
public BasicView(String name) {
super(name);
Button button = new Button("Show alert");
button.setOnAction(e -> {
Alert alert = new Alert(AlertType.INFORMATION, "This is an Alert!");
alert.showAndWait();
});
setCenter(new StackPane(button));
}
}
If it isn't the case for you, post your build.gradle and any exception you may have.
hey everyone i have an issue with thymeleaf and my static html pages
to be more specific i have a spring mvc web application am using also spring security , well in my login page i want to use thymeleaf so can spring security communicate with client layer in the other side i don't want to include thymeleaf in my all html pages cause am going to use AngularJs
I tried to put the login in templates folder and the other's in the static folder but id doesn't work
this is my thymleaf configuration class
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.thymeleaf.spring3.SpringTemplateEngine;
import org.thymeleaf.spring3.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
#Configuration
public class ThymeleafConfig {
#Bean
public ServletContextTemplateResolver templateResolver() {
ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
resolver.setPrefix("/WEB-INF/vues/");
resolver.setSuffix(".html");
resolver.setTemplateMode("HTML5");
resolver.setOrder(1);
return resolver;
}
#Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine engine = new SpringTemplateEngine();
engine.setTemplateResolver(templateResolver());
return engine;
}
#Bean
public ThymeleafViewResolver thymeleafViewResolver() {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
return resolver;
}
}
my problem is i don't want Thymeleaf included in my all pages you know XHTML is pretty annoying with closing the html tag
any guide will be thankfull
Well i think you dont have to use the XHTML Syntax if u are not including thymleaf into the specific page.
I'm using google app engine with JSF. i want to call a function when user press that button:
<p:commandButton value="Ajax Submit" action="#{todo.test}" />
and I put todo under src->package test123.
package test123;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
#ManagedBean(name="todo")
#SessionScoped
public class Todo {
public void test(ActionEvent event){
System.out.println("lol");
}
}
but when i press button, error occurs:
sth like this:
javax.el.MethodNotFoundException: /Template/default.xhtml #39,38 action="#{todo.test}": Method not found: test.Todo#7929b073.test()
am i wrong? or do i need to do some configurations ?
Thanks
Use actionListener="#{todo.test}" or try:
public void test()
{
System.out.println("lol");
}
See here for more details: Differences between action and actionListener
I just started to play with MemCache in Google Apps Engine and every time I create CacheFactory I get this error :
net.sf.jsr107cache.CacheException:
Could not find class: 'com.google.appengine.api.memcache.jsr107cache.GCacheFactory'
at net.sf.jsr107cache.CacheManager.getCacheFactory(CacheManager.java:46)
I'm using Apps Engine SDK "1.5.0.1 - 2011-05-16" ( which is the latest ). I tested this in my local.
Anybody know how to fix this issue?
Here is my snippet of my code.
#SuppressWarnings("rawtypes")
Map props = new HashMap();
//props.put(GCacheFactory.EXPIRATION_DELTA, 3600);
try {
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
cache = cacheFactory.createCache(props);
if(cache.containsKey("userAgent"))
{
userAgent = (String)cache.get("userAgent");
}else
{
cache.put("userAgent", userAgent+" from MEMCache");
}
} catch (CacheException e) {
e.printStackTrace();
}
This should be fixed in App Engine SDK 1.5.0.1.
Make sure you are importing:
import net.sf.jsr107cache.CacheException;
import net.sf.jsr107cache.CacheFactory;
import net.sf.jsr107cache.CacheManager;
I don't have any "Could not find class" error with the following sample code
package classnotfoundtest;
import net.sf.jsr107cache.CacheException;
import net.sf.jsr107cache.CacheFactory;
import net.sf.jsr107cache.CacheManager;
import java.io.IOException;
import javax.servlet.http.*;
#SuppressWarnings("serial")
public class ClassnotfoundtestServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
try {
CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
resp.setContentType("text/plain");
resp.getWriter().println("Hello, world");
} catch (CacheException e) {
e.printStackTrace(resp.getWriter());
}
}
}
Eclipse projects created with App Engine plugin 1.5.0 had the broken jsr107cache-1.1.jar added to their war/WEB-INF/lib directory.
Updating the SDK and plugin doesn't alter your projects, you'll need to fix that yourself.