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
Related
I'm trying to deal with a strange behavior of G+ sharing.
I wrote two lightweight HTML pages to demonstrate my problem. Those pages are almost identical except images in their bodies. On the first page, the content image is much larger that the og:image. On the second page, the content image is slightly smaller than the og:image.
First HTML page:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta property="og:title" content="Test page" />
<meta property="og:description" content="This is page for G+ strange behavior testing." />
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/wikimania2014/thumb/e/e2/Ask-Logo-Small.jpg/250px-Ask-Logo-Small.jpg" />
<title>Test page</title>
</head>
<body>
<div>
<p>Hello world!</p>
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/Fronalpstock_big.jpg" />
</div>
</body>
</html>
Second HTML page:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta property="og:title" content="Test page" />
<meta property="og:description" content="This is page for G+ strange behavior testing." />
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/wikimania2014/thumb/e/e2/Ask-Logo-Small.jpg/250px-Ask-Logo-Small.jpg" />
<title>Test page</title>
</head>
<body>
<div>
<p>Hello world!</p>
<img src="http://previewcf.turbosquid.com/Preview/2014/07/05__19_56_51/01.jpg90ddaa05-e3a9-4607-b466-29ade8412934Small.jpg" />
</div>
</body>
</html>
The problem is that in the first case, G+ shows the image from the body (ignores og:image). In the second case, G+ shows og:image as expected.
I've also tried using schema microdata, but the behavior is the same.
I share pages using https://plus.google.com/share?url=PAGE_URL.
Solved! The reason was that in the second case, the og:image had smaller width than G+ requires.
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 $
I hardly know anything about POST request or api's , so the more explicity you can make things, the better.
I'm going through the description of adding a reCAPTCHA to my site but I'm stuck on the verification portion. Here's the part I'm stuck on: http://code.google.com/apis/recaptcha/docs/verify.html
I don't know how to do a POST request. If someone could explain this portion to me that would help greatly.
Here's the code I have on my site so far, copied directly from http://code.google.com/apis/recaptcha/docs/display.html#Standard:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<body>
<!-- ... your HTML content ... --> <form action="" method="post"> <!-- ... your form code here ... --> <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=public key"> </script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=public key" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript> <!-- ... more of your form code here ... --> </form> <!-- ... more of your HTML content ... -->
</body>
</html>
either use te recaptcha PHP/Perl/Asp/.. plugin or use the recaptcha ajax library which handles everything with javascript so you dont need server side scripts.
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.. :)
I have problem with <pre>, here is my code, and the screenshot is attached below. How to remove the indents?
%pre.code
:escaped
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
<form>
<input type="text" name="empID" />
<input type="submit"/>
</form>
</body>
</html>
You need to use the #preserve helper to convert the newlines in the pre to newline entities, like so:
%pre.code
= preserve do
:escaped
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
<form>
<input type="text" name="empID" />
<input type="submit"/>
</form>
</body>
</html>
In the future, you'll be able to nest filters, so you can do :preserve:escaped.
When representing "pre" like text from a variable inside a div or other tag, use
.text.plain= preserve(#mail.body.to_s)
along with CSS "white-space: pre-wrap;". Use the one-line version, because the two-line will still indent the first line.
/ BAD: Will leave the first line incorrectly indented!
.text.plain
= preserve(#mail.body.to_s)