JSF with google app engine. not sure how to call method in managedbean - google-app-engine

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

Related

How to update a property of an object/entity when a button click occurs in Springboot & React

I'm facing a problem which I cannot seem to resolve.
I have an entity which has a property (specifically a string) with a value of 'In magazijn':
package com.Code.Pakket.management.model;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.jpa.repository.Modifying;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
//Men maakt een JPA entity class zodat hibernate met onze data kan werken.
#Entity
public class Pakketje {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private int code;
private String status ="In magazijn";
public Pakketje() {
}
I would like this string to change when a button click occurs in the react application. The specific object from which the value should be changed is already existing inside of the database, and only the value "In magazijn" should be changed to "Onderweg". This value should change inside of the database.
I have tried the following inside of the service class:
#Override
public String StatusOnderweg(Pakketje pakketje) {
return pakketjeRepository.save(pakketje.setStatus("Onderweg"));
}
So "Pakketje pakketje" is the object of which the string should be changed. I thought about saving the specific object once more to the database (even tough the object already exists) and save it with another string.
My Repository:
package com.Code.Pakket.management.repository;
import com.Code.Pakket.management.model.Pakketje;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
//https://www.javadevjournal.com/spring-boot/spring-boot-with-hibernate/ -- Punt5.
#Repository
public interface PakketjeRepository extends JpaRepository<Pakketje,Integer> {
}
I just don't have an idea how to make this code with a repository, service and controller structure... Any advice?
Thanks in advance.

Capacitor Plugin shows as undefined on android build

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);
}});
}
}

Error while updating 'end' in shadow node of type: BVLinearGradient

I get "Error while updating 'end' in shadow node of type: BVLinearGradient" error when i run my react native app and the error seems to emanate from my MainApplication.java file here is my code:
package com.*;
import com.BV.LinearGradient.LinearGradientPackage;
import com.facebook.react.ReactPackage;
import com.horcrux.svg.SvgPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativenavigation.NavigationApplication;
import com.wheelpicker.WheelPickerPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends NavigationApplication {
#Override
public boolean isDebug() {
// Make sure you are using BuildConfig from your own application
return BuildConfig.DEBUG;
}
#Override
public List<ReactPackage> createAdditionalReactPackages() {
// Add the packages you require here.
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
new WheelPickerPackage(),
new VectorIconsPackage(),
new SvgPackage(),
new LinearGradientPackage()
);
}
}
Please help me resolve this
This is a bug with the react-native-linear-gradient. The issue is in open status. For the time being, there are 2 solutions-
Replace start with startPoint and end with endPoint props for <LinearGradient/>
Downgrade react-native version to 0.50.3
The details for this issue is below:
https://github.com/react-native-community/react-native-linear-gradient/issues/246

Unable to click on particular element. I have tried locating object using xpath, css, creating your own xpath and css but none of the is working

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.safari.SafariDriver;
public class XpathDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new SafariDriver();
driver.get("http://www.amazon.in/");
//driver.findElement(By.xpath("b[style='padding-right:3px; font-weight:normal;font-size: 18px;text-transform: uppercase;']")).click();
driver.findElement(By.cssSelector("#Sign in")).click();
//driver.findElement(By.cssSelector("[class = '.nav-action-inner']")).click();
//driver.findElement(By.cssSelector("#ap_email")).sendKeys("vit.yoamitsharma#gmail.com");
//driver.findElement(By.xpath("html/body/div[1]/header/div/div[1]/div[4]/div[7]/div[2]/a/span")).click();
driver.findElement(By.linkText("Sign in")).click();
}
}
Whats the error here?
I see 2 un-commented lines trying to click sign in button.
Have you tried with xpath checker? following should work and it worked for me
driver.findElement(By.xpath("html/body/div[1]/header/div/div[1]/div[4]/div[7]/div[2]/a/span")).click();

Error in creating Cache in Google Apps Engine. net.sf.jsr107cache.CacheException

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.

Resources