"Could not find action or result" in Struts - struts

I'm currently creating a web application using the jquery+struts plugin. It also uses hibernate. I have two web pages already, the other one works perfectly fine but when I created another one, it threw an error saying that the action cannot be found. The error is:
ERROR (org.apache.struts2.dispatcher.Dispatcher:38) - Could not find action or result
/mims_agchem/index.action
No result defined for action com.agchem.mims.actions.Index and result success
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
These are my codes:
struts.xml
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" />
<package name="admin" namespace="/admin" extends="hibernate-default,json-default,struts-default">
<interceptors>
<interceptor-stack name="showcaseStack">
<interceptor-ref name="defaultStackHibernate"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="showcaseStack"/>
<action name="*" class="com.agchem.mims.actions.admin.{1}">
<result>/jsp/admin/{1}.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
</package>
<package name="general" namespace="/" extends="hibernate-default,json-default,struts-default">
<interceptors>
<interceptor-stack name="showcaseStack">
<interceptor-ref name="defaultStackHibernate"/>
</interceptor-stack>
</interceptors>
<action name="index" class="com.agchem.mims.actions.Index">
<result name="success">/jsp/index.jsp</result>
<result name="redirect" type="redirect">${redirectUrl}</result>
</action>
</package>
Index.java
package com.agchem.mims.actions;
import com.opensymphony.xwork2.ActionSupport;
public class Index extends ActionSupport {
private static final long serialVersionUID = 1475579903320095412L;
#Override
public String execute() throws Exception {
return SUCCESS;
}
}
index.jsp
<?xml version="1.0" encoding="utf-8"?>
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>AGCHEM MIMS</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="struts2,jquery, hibernate, plugin,showcase, grid" />
<meta http-equiv="description" content="Project Maintenance" />
<link href="../styles/main.css" rel="stylesheet" type="text/css" />
<link href="../styles/menu.css" rel="stylesheet" type="text/css" />
<sj:head
loadAtOnce="true"
compressed="false"
jquerytheme="mims"
customBasepath="../themes"
loadFromGoogle="false"
debug="true"
/>
<script type="text/javascript" src="../js/menu.js"></script>
</head>
<body>
<s:url id="adm201" action="ADM201"/>
<s:url id="adm210" action="ADM210"/>
<s:url id="adm301" action="ADM301"/>
<s:url id="adm310" action="ADM310"/>
<div id="menu">
<ul class="menu" style="width: 765px">
<li>
<sj:a href="../general/main_admin.html" targets="main">Home</sj:a>
</li>
<li class="current">
<sj:a href="#" class="parent">Project</sj:a>
<div>
<ul>
<li><sj:a href="%{adm201}" class="current" targets="main">Create New Project</sj:a></li>
<li><sj:a href="%{adm210}" targets="main">Search Projects</sj:a></li>
</ul>
</div>
</li>
<li>
<sj:a href="#" class="parent">User</sj:a>
<div>
<ul>
<li><sj:a href="%{adm301}" targets="main">Create New User</sj:a></li>
<li><sj:a href="%{adm310}" targets="main">Search Users</sj:a></li>
</ul>
</div>
</li>
</ul>
</div>
<sj:div id="main" href="%{adm201}">
<img id="indicator" src="../images/indicator.gif" alt="Loading..."/>
</sj:div>
</body>
</html>
Hope someone could explain and help me on my problem. Thanks a lot!
Regards,
Honey =)

The other page already worked. With just some refresh and restarts on the server, the page just worked fine. :) Weird though.. :)

Related

Include view parameters in h:link

I have a problem when adding view parameters to a <h:link includeViewParams="true" /> - they are not added to the rendered link. I am using Mojarra 2.3.9.
Template /WEB-INF/templates/main.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<!-- Some headers -->
</h:head>
<h:body>
<f:view>
<ui:insert name="metaContent" />
<div class="container-fluid" id="mainContent">
<ui:insert name="mainContent" />
</div>
</f:view>
</h:body>
</html>
Template being used on page test.xhtml
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:o="http://omnifaces.org/ui"
template="/WEB-INF/templates/main.xhtml">
<ui:define name="metaContent">
<f:metadata>
<f:viewParam name="id" value="#{myBean.obj}" required="true">
<f:validator validatorId="myIdVvalidator" />
<f:converter converterId="myConverter" />
</f:viewParam>
</f:metadata>
</ui:define>
<ui:define name="mainContent">
<!-- Simply reference current page -->
<h:link outcome="test.xhtml" includeViewParams="true">
My link
</h:link>
</ui:define>
</ui:composition>
Update
If I remove the attribute value of f:viewParam as well as the f:converterand f:validator child elements, the link is rendered as expected. Why can this cause a problem? The Bean myBean is #RequestScoped

Selenium Actions click() method is not working

I am using Firefox Quantum 63.0.1 (64 bit) with Selenium 3.14. I can use the following code to click on a drop down list and it works fine.
WebElement elementToClickAndHold= driver.findElement(By.cssSelector("#eventTypeInd"));
elementToClickAndHold.click();
But the following code does not work.
WebElement elementToClickAndHold= driver.findElement(By.cssSelector("#eventTypeInd"));
Actions builder = new Actions(driver);
builder.click(elementToClickAndHold);
Obviously I could just use the WebElement.click() method but I need to use some of the Actions methods for other issues so I need to figure out why the Actions methods are not working.
The html for the drop down list is:
<div class="row">
<div class="col-xs-12 col-sm-3 text-right">
<span class="required">*</span><label for="eventTypeInd" >Type of Event:</label>
</div>
<div class="col-xs-12 col-sm-9 text-left">
<select name="eventTypeInd" tabindex="1" onchange="dirtyFlag()" id="eventTypeInd"><option value=""></option>
<option value="B">Bypass</option>
<option value="S">SSO (Overflow)</option></select>
</div>
</div>
The meta data for the html page is
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

How can you add Rich Pins Meta Tags for Bigcommerce?

I'd like to enable my Bigcommerce website for Rich Pins in Pinterest. What are the appropriate meta tags to do this?
The above is incorrect, it should actually be as follows:
<meta property="og:type" content="product" />
<meta property="og:price:amount" content="%%GLOBAL_ProductPrice%%" />
<meta property="og:price:currency" content="USD" />
<meta property="og:availability" content="in stock"/>
Below are the rich pins meta tags that you can put it in your Bigcommerce template
File. product.html
just after %%Panel.HTMLHead%%
<meta property="og:type" content="product" />
<meta property="product:price:amount" content="%%GLOBAL_RetailPrice%%"/>
<meta property="product:price:currency" content="AUD" />
<meta property="og:availability" content="in stock"/>
All others tags are already provided from BigCommerce Template
in HTMLhead.html file
%%GLOBAL_AdditionalMetaTags%%
But if something is missing here is the full list you can use in addition to above.
<meta property="og:site_name" content="YOURSITE.COM" />
<meta property="og:title" content="%%GLOBAL_ProductName%%" />
<meta property="og:url" content="%%PageContent%%" />
<meta itemprop="description" content="%%ProductDescription%%" />
<meta property="og:image" content="%%GLOBAL_ThumbImageURL%%"/>
Unfortunately, neither will work if you load additional products on your page, for example with "Related" or "Recently Viewed" blocks as it will load the last product on the page as the product price.
Instead you can use the Schema.org Semantic Markup option instead.
The following code at the bottom of my productdetails.html page passed the Pinterest validator.
<div itemscope itemtype="http://schema.org/Product">
<meta itemprop="name" content="%%GLOBAL_ProductName%%" />
<meta itemprop="image" content="%%GLOBAL_ThumbImageURL%%" />
<meta itemprop="description" content="%%Page.MetaDescription%%">
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<meta itemprop="price" content="%%GLOBAL_ProductPrice%%">
<meta itemprop="priceCurrency" content="USD" />
<meta itemprop="availability" itemtype="http://schema.org/ItemAvailability" content="http://schema.org/InStock" />
</div>
</div>

Can flowScope entries be accessed from JSPs? ("Property ... not found on type org.springframework.webflow.core.collection.LocalAttributeMap")

I'm learning Spring and webflow and I'm having trouble with something which seems like it should be simple. My flow is capturing a query string parameter and stashing it in a flow-scoped variable when the flow begins. I'm trying to echo it on the first view-state. Errors ensue.
Here's the flow definition:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<on-start>
<set name="flowScope.foo" value="requestParameters.fubar" />
</on-start>
<view-state id="step1" view="../jsp/step1.jsp">
<transition on="next" to="step2" />
</view-state>
<view-state id="step2" view="../jsp/step2.jsp">
<transition on="next" to="step3" />
<transition on="prev" to="step1" />
</view-state>
<view-state id="step3" view="../jsp/step3.jsp">
<transition on="prev" to="step2" />
<transition on="next" to="done" />
</view-state>
<end-state id="done" view="endView" />
<end-state id="cancelled" view="../jsp/cancelledView.jsp" />
<global-transitions>
<transition on="cancel" to="cancelled" />
</global-transitions>
</flow>
step1.jsp:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%# taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Step 1</title>
</head>
<body>
This is step 1
<h1>flowRequestContext.flowScope: ${flowRequestContext.flowScope}</h1>
<h1>flowRequestContext.flowScope["foo"]: ${flowRequestContext.flowScope["foo"]}</h1>
<h2>${flowScope}</h2>
<c:if test="${empty flowScope}">
<h1>FLOW SCOPE IS EMPTY!</h1>
</c:if>
<c:if test="${!empty flowScope}">
<h1>FLOW SCOPE IS *NOT* EMPTY!</h1>
</c:if>
<c:if test="${empty flowRequestContext.flowScope}">
<h1>flowRequestContext.FLOW SCOPE IS EMPTY!</h1>
</c:if>
<c:if test="${!empty flowRequestContext.flowScope}">
<h1>flowRequestContext.FLOW SCOPE IS *NOT* EMPTY!</h1>
</c:if>
<form:form id="myForm">
<input type="submit" id="next" name="_eventId_next" value="Next" />
<input type="submit" name="_eventId_cancel" value="Cancel" />
</form:form>
</body>
</html>
Resulting error:
javax.el.PropertyNotFoundException: Property 'foo' not found on type org.springframework.webflow.core.collection.LocalAttributeMap
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:223)
javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:200)
javax.el.BeanELResolver.property(BeanELResolver.java:311)
javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
...
If I omit the attempt to access the key "foo" the page renders with the following output (where the query string is ?fubar=baz):
This is step 1
flowRequestContext.flowScope: map['foo' -> 'baz', 'viewScope' -> map[[empty]]]
FLOW SCOPE IS EMPTY!
flowRequestContext.FLOW SCOPE IS *NOT* EMPTY!
It looks like the identifier flowRequestContext.flowScope does refer to a map, and it looks like it does contain the key and value I would expect... but if I try to access it like a map in EL it doesn't cooperate.
just use ${foo} everything in your flowscope should be accessible with $

jquery input click function not triggering

I tried changing the script to the following and it still doesn't trigger the event.. am I missing something?
$('#page1').live('pageshow',function(event) {
$("#radioyes").click(function(){
$("p").hide();
});
});
I also tried pagebeforecreate but the result is the same.. :(
I am trying a simple jquery mobile page and testing on chrome portable. However, in the following code, the input click event isn't working where as button click works. I also tried "input#radioyes" as "div>fieldset>input#radioyes" and still doesnt work.
<!DOCTYPE html>
<html>
<head>
<title>Background check </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="images/touch-icon-iphone.png" />
<link rel="apple-touch-icon" sizes="72x72" href="images/touch-icon-ipad.png" />
<link rel="apple-touch-icon" sizes="114x114" href="images/touch-icon-iphone4.png" />
<script type="text/javascript" src="jQuery/jquery.js"></script>
<script type="text/javascript" src="jQuery/jquery.mobile.min.js"></script>
<link rel="stylesheet" href="jQuery/jquery.mobile.min.css" />
<!-- JQuery Date Picker components -->
<link rel="stylesheet" href="jQuery/jquery.ui.datepicker.mobile.css" />
<script src="jQuery/jQuery.ui.datepicker.js"></script>
<script src="jQuery/jquery.ui.datepicker.mobile.js"></script>
<link rel="stylesheet" href="css/folo.css" />
<script type="text/javascript">
$('#page1').live('pageshow',function(event) {
$("#radioyes").click(function(){
$("p").hide();
});
});
</script>
</head>
<body >
<div data-role="page" id="page1" data-theme="a" data-title="PAGE1">
<div data-role="header">
<h1>"PAGE1"</h1>
</div><!-- /header -->
<div data-role="content" >
<p> Welcome. </p>
<div id="SSN">
<label for="basic">SSN: </label>
<input name="ssn" id="textSSN" value="" data-theme="a" />
</div>
<div id="first">
<label for="first">First Name:</label>
<input name="input_first" id="input_first" value="" data-theme="d" />
</div>
<div id="last">
<label for="last">Last Name:</label>
<input name="input_last" id="input_last" value="" data-theme="d" />
</div>
<button id="btn1">Click me</button>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-role="fieldcontain">
<legend>Have you used other last name?</legend>
<input type="radio" name="radio-choice" id="radioyes" value="yes" />
<label for="radioyes">Yes</label>
<input type="radio" name="radio-choice" id="radio-no" value="No" checked="checked" />
<label for="radio-no">No</label>
</fieldset>
<div id="otherlast">
<label for="otherlast">Other Last Name:</label>
<input name="input_otherlast" id="input_otherlast" value="" data-theme="d" />
</div>
</div>
<div id="dob">
<label for="date">Date Of Birth:</label>
<input type="date" class="datepicker" name="date" id="my_date" value="01/19/1975" text="01/19/1975" />
</div>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>
</html>
Appreciate any help.. The version of Jquery is 1.7.1 1.6.4 downloaded and the jquery mobile is the latest version.
You cannot use $(document).ready in jquery mobile here's an documentation about it
Also here's an answer to a similiar question
jQM 1.0 does not support jQuery 1.7.x please use jQuery 1.6.4 ( Source )
jQM uses pageInit(), not $(document).ready() ( Source )
Also jQM adds additional markup to your page so $("p").hide(); might be hiding as expected but the additional markup might still be visible. I would suggest using an id for the span elements
UPDATE:
Try this
$('#page1').live('pageshow',function(event) {
$("#radioyes").bind( "change", function(event, ui) {
$("p").hide();
});
});
Live Example:
http://jsfiddle.net/CZLcR/9/
Docs for Radio Events:
http://jquerymobile.com/demos/1.0/docs/forms/radiobuttons/events.html