Hey Hi Guys I am Facing Some issue Please Guide me What to do
I have made an app part and I am trying to add it Dashboard which Open when some one login in intranet in sharepoint account.I am doing the same steps as shown in above link
http://www.codeproject.com/Articles/524232/StepplusbyplusStepplusguideplustopluscreateplusapl
But In this Link the guy has chosen sharepoint hosting and I am using on Premise Hosting Please Guide me what should I am able to get the app part but in app part I am getting error messages.Picture are attched with errors..
What I have done as Follows:
1)Created a client web part in VS,Code is As Follows:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="ClientWebPart1.aspx.cs" Inherits="BI_ApplicationWeb.Pages.ClientWebPart" %>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
// Set the style of the client web part page to be consistent with the host web.
(function () {
'use strict';
var hostUrl = '';
if (document.URL.indexOf('?') != -1) {
var params = document.URL.split('?')[1].split('&');
for (var i = 0; i < params.length; i++) {
var p = decodeURIComponent(params[i]);
if (/^SPHostUrl=/i.test(p)) {
hostUrl = p.split('=')[1];
document.write('<link rel="stylesheet" href="' + hostUrl + '/_layouts/15/defaultcss.ashx" />');
break;
}
}
}
if (hostUrl == '') {
document.write('<link rel="stylesheet" href="/_layouts/15/1033/styles/themable/corev15.css" />');
}
})();
</script>
</head>
<body>
</body>
</html>
2)Added code path to open In Iframe in Element.xml :Code is written Below
<
?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ClientWebPart Name="ClientWebPart" Title="ClientWebPart Title" Description="ClientWebPart Description" DefaultWidth="800" DefaultHeight="450">
<Content Type="html" Src="~remoteAppUrl/Pages/AppPart/ClientWebPart1.aspx" />
<Properties>
</Properties>
</ClientWebPart>
</Elements>
3)Created page which is shown In Iframe Using below code:
<%# Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<WebPartPages:AllowFraming ID="AllowFraming1" runat="server" />
<div>Simple Client App Part</div>
Error Message I am Getting In App Part Is Like This
This page can’t be displayed
•Make sure the web address https://localhost:44300 is correct.
•Look for the page with your search engine.
•Refresh the page in a few minutes.
If you are getting the below error this https://localhost:44300. Please check whether your app is deployed or not properly.
Please use below mentioned url to create your development machine for SharePoint hosted apps
https://msdn.microsoft.com/en-us/library/office/fp179923.aspx
I'm developing a liferay portlet. This is not my first time doing that, but a get a simple error that I can't understand why I'm getting this error. When I click submit button I get this error
The requested resource was not found. "http://localhost:8081/addProduct"
It's more than hours I'm trying to solve it and I know that I have made a silly mistake. Can any body help me solve this problem? Any help is appreciated in advance. Here is my jsp code:
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%# taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%# page import="javax.portlet.PortletURL" %>
<portlet:defineObjects />
This is the <b>ServiceBuilderTest</b> portlet.
<portlet:actionURL var="addProduct" name="addProductAction"/>
<aui:form method="post" action="addProduct">
<aui:fieldset>
<aui:input name="productName" label="Product Name"></aui:input>
<aui:input name="userID" label="User ID"></aui:input>
<aui:input name="companyID" label="company ID"></aui:input>
<aui:input name="groupID" label="Group ID"></aui:input>
<aui:input name="serialNumber" label="Serial Number"></aui:input>
<aui:button type="submit" value="Submit"></aui:button>
</aui:fieldset>
</aui:form>
And this is my portlet class code:
public class ServiceBuilderPortlet extends MVCPortlet{
public void addProductAction(ActionRequest actionReauest, ActionResponse actionResponse) throws SystemException, PortalException
{
String productName = actionReauest.getParameter("productName");
String userID = actionReauest.getParameter("userID");
String companyID = actionReauest.getParameter("companyID");
String groupID = actionReauest.getParameter("groupID");
String serialNumber = actionReauest.getParameter("serialNumber");
PRProduct product = PRProductLocalServiceUtil.addProduct(Long.parseLong(companyID), Long.parseLong(groupID), productName,
serialNumber, Long.parseLong(userID));
}
}
make it
<portlet:actionURL var="addProduct" name="addProductAction"/>
<aui:form method="post" action="<%=addProduct%>">
...
actually, I'd see it as best practice to not name the action "addProductAction", but just "addProduct", so the changes would be as such (including one line of java, the rest looks good (visually, not tried/tested):
<portlet:actionURL var="addProduct" name="addProduct"/>
<aui:form method="post" action="<%=addProduct%>">
....
and
public class ServiceBuilderPortlet extends MVCPortlet{
public void addProduct(ActionRequest request, ActionResponse response) throws SystemException, PortalException {
// ...
}
}
I am working on real time vehicle tracking project.
I am getting vehicle location after every 6 sec and I store lat and long in static variable each time.
I want to show vehicle moving on Google map after change location using ajax.
I have written code as:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%# taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%# taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%# taglib uri="http://code.google.com/p/gmaps4jsf/" prefix="m"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META HTTP-EQUIV=" " CONTENT="6">
<title>Insert title here</title>
<script
src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAtRLgopSfFn_inKV4Mb4dwRQrh986W3YN5ROngdOVRv-81htxfBSHsTcVUm4HRkCt9bSp5mP_3_snrw"
type="text/javascript">
</script>
</head>
<body>
<f:view>
<h:form id="aaaa">
<h:panelGrid columns="2">
<m:map id="mp" width="500px" height="500px" latitude=" #{mp3.lat} "
longitude=" #{mp3.lon}" zoom="15">
<m:mapControl name="GMapTypeControl" />
<m:mapControl name="GLargeMapControl"
position="G_ANCHOR_BOTTOM_RIGHT" />
<m:marker id="m" latitude=" #{mp3.lat} " longitude=" #{mp3.lon}">
<m:htmlInformationWindow htmlText="Start<br> " />
<a4j:support event="onchange" action=" " reRender="m"></a4j:support>
</m:marker>
</m:map>
</h:panelGrid>
<h:commandButton value="Start" action="#{mp3.meth}" />
<h:commandButton value="Path Map" action="pathmp" />
</h:form>
</f:view>
</body>
</html>
My question is how to move vehicle marker on google map using ajax a4j without reloading all page?
technology i have used are
- jsf
- richfaces
- a4j
- javaBean
Thanks
The Issue:
We have a Java web application, based on Apache MyFaces Trinidad. We are facing some problems when trying to partial submit (that's it: via Ajax) a form, when a field contains some special characters, such as Ñ, á, etc.
When we write a value like camión at the text field, the resulting message is Hola cami (it drops the special char, and the next one).
The application server we are runnign our code at is IBM WebSphere AS 7.0.
This behaviour has been observed on IExplorer and Firefox browsers, all run from Windows XP Professional (spanish version).
Main code snippets:
UPDATE: based on lkdg's answer (thanks), I have updated the JSP and resulting HTML code snippets.
JSP Page Code:
<%#page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%# taglib uri="http://myfaces.apache.org/trinidad" prefix="tr" %>
<%# taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh" %>
<f:view>
<tr:document>
<trh:head title="Prueba de AJAX con todas las Cabeceras">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</trh:head>
<tr:form>
<tr:panelHorizontalLayout halign="left">
<f:facet name="separator">
<tr:spacer width="10" height="5"/>
</f:facet>
<tr:inputText id="elCampo" label="Your name" value="#{commandButtonBean.name}"
requiredMessageDetail="Name is required"
/>
<tr:commandButton id="sayHello" text="Say Hello"
partialSubmit="true"
action="#{commandButtonBean.sayHello}"
/>
</tr:panelHorizontalLayout>
<tr:spacer height="15px"/>
<tr:outputText value="#{commandButtonBean.message}" partialTriggers="sayHello"
inlineStyle="font-weight: bold;"/>
</tr:form>
</tr:document>
</f:view>
This is the resulting HTML output (removed some empty lines):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--Start: org.apache.myfaces.trinidad.Document["j_id_jsp_1876237926_1"]--><html dir="ltr" lang="es-ES">
<head>
<meta name="generator" content="Apache MyFaces Trinidad">
<link rel="stylesheet" charset="UTF-8" type="text/css" href="/ModuloTrinidadPilotoWeb/adf/styles/cache/bigfont-desktop-nur72r-ltr-gecko.css">
</head>
<!--Start: org.apache.myfaces.trinidad.Document["j_id_jsp_1876237926_1"]-->
<body onload="_checkLoad()" onunload="_checkUnload(event)"><script type="text/javascript">var _AdfWindowOpenError='Se ha detectado un bloqueo de ventana emergente en el explorador. Estos bloqueos interfieren con el funcionamiento de esta aplicación. Desactívelo o permita elementos emergentes desde esta dirección.';</script><script type="text/javascript" src="/ModuloTrinidadPilotoWeb/adf/jsLibs/Common1_2_10.js"></script><!--Start: org.apache.myfaces.trinidad.Document["j_id_jsp_1876237926_1"]--><div id="tr_pprBlockingDiv" onclick="return _pprConsumeClick(event);" style="position:absolute;left:0;top:0;width:0;height:0;cursor:wait;" onkeydown="return false;" onkeyup="return false;" onmousedown="return false;" onmouseup="return false;" onkeypress="return false;"></div><a name="top"></a>
<noscript>Esta página utiliza JavaScript y necesita un explorador activado para JavaScript. Su explorador no está activado para JavaScript.</noscript>
<!--Start: org.apache.myfaces.trinidad.Head["j_id_jsp_1876237926_2"]-->
<head>
<title>Prueba de AJAX con todas las Cabeceras</title>
<meta name="generator" content="Apache MyFaces Trinidad">
<link rel="stylesheet" charset="UTF-8" type="text/css" href="/ModuloTrinidadPilotoWeb/adf/styles/cache/bigfont-desktop-nur72r-ltr-gecko.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<!--Start: org.apache.myfaces.trinidad.Form["j_id_jsp_1876237926_3"]-->
<form id="j_id_jsp_1876237926_3" name="j_id_jsp_1876237926_3" style="margin:0px" method="POST" onkeypress="return _submitOnEnter(event,'j_id_jsp_1876237926_3');" action="/ModuloTrinidadPilotoWeb/jsp/sgtc/pruebaAjax2.faces"><!--Start: org.apache.myfaces.trinidad.Panel["j_id_jsp_1876237926_4"]--><table cellpadding="0" cellspacing="0" border="0" summary=""><tr>
<td><!--Start: org.apache.myfaces.trinidad.Input["elCampo"]--><table id="elCampo__xc_" class="af_inputText" cellpadding="0" cellspacing="0" border="0" summary=""><tr>
<td class="af_inputText_label" nowrap><span id="elCampo::icon" style="display:none;"><a name="_msgAnc_elCampo" title="Error" class="AFErrorIconStyle">X</a></span> <label for="elCampo">Your name</label></td>
<td valign="top" nowrap class="AFContentCell"><!--Start: org.apache.myfaces.trinidad.Input["elCampo"]--><input id="elCampo" name="elCampo" class="af_inputText_content" size="30" type="text"></td>
</tr><tr>
<td></td>
<td class="AFComponentMessageCell"><!--Start: org.apache.myfaces.trinidad.Input["elCampo"]--><span id="elCampo::msg" class="OraInlineErrorText"></span></td>
</tr></table></td>
<td><!--Start: org.apache.myfaces.trinidad.Object["j_id_jsp_1876237926_5"]--><img src="/ModuloTrinidadPilotoWeb/adf/images/t.gif" alt="" width="10" height="5"></td>
<td><script type="text/javascript">var _pprUpDatemode=false;function _adfspu(f,v,e,s,o){_pprUpdateMode=true;if(!o)o=new Object();if(e)o.event=e;if(s)o.source=s;_submitPartialChange(f,v,o);}</script><!--Start: org.apache.myfaces.trinidad.Command["sayHello"]-->
<button id="sayHello" name="sayHello" type="button" onclick="TrPage._autoSubmit('j_id_jsp_1876237926_3','sayHello',event,1);return false;" class="af_commandButton">Say Hello</button>
</td>
</tr></table><!--Start: org.apache.myfaces.trinidad.Object["j_id_jsp_1876237926_8"]--><div style="margin-top:15px"></div><!--Start: org.apache.myfaces.trinidad.Output["j_id_jsp_1876237926_9"]--><span id="j_id_jsp_1876237926_9" style="font-weight: bold;"></span><input type="hidden" name="org.apache.myfaces.trinidad.faces.FORM" value="j_id_jsp_1876237926_3"><!--Start: org.apache.myfaces.trinidad.Form--><span id="tr_j_id_jsp_1876237926_3_Postscript"><input type="hidden" name="javax.faces.ViewState" value="!-4fd3ee50"><script type="text/javascript">function _j_id_jsp_1876237926_3Validator(f,s){return _validateInline(f,s);}var j_id_jsp_1876237926_3_SF={};</script></span><script type="text/javascript">_submitFormCheck();</script></form>
</body>
<!--Created by Apache Trinidad (Apache MyFaces Trinidad API - 1.2.10/Apache MyFaces Trinidad Impl - 1.2.10), skin:bigfont.desktop (bigfont)--></html>
The CommandButton bean code:
public class CommandButtonBean {
public String name;
public String message;
public String sayHello(){
message = "Hola " + name;
return "";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
Of course, the command button is configured at faces-config.xml (I think that this snippet is not relevant).
Attempted fixes so far:
We have checked the charset encoding at different levels (application, JVM, etc). It seems to be aligned between the differen layers.
Also, we have included at web.xml the next context parameter:
<context-param>
<param-name>PARAMETER_ENCODING</param-name>
<param-value>UTF-8</param-value>
</context-param>
We have logged what is the value
passed as an argument to the
setName method, for if it could be
an error at writing the response. The
value passed is already wrong.
We have tried to write a web Filter,
to set the request charset to UTF-8 (just in
case, you know). But when logging the
parameter values at the filter, we
got the wrong value too.
At last we removed the
partialSubmit attribute of the
submit button, and got the right
value. But this won't really fix our
problem, as we are trying to
implement some inline searches and
validations (we don't want to repaint
the whole page).
So, when we send a normal POST message, we get the expected result, but when we try to use the Ajax approach, we loose these special characters.
And, at last, The Question:
Have you any suggestions on how to fix this issue?
Thank you very much.
This is a known issue with trinidad&WAS: http://www.mail-archive.com/dev#myfaces.apache.org/msg46298.html . You will have to make a small modification to two js files, you need to encode the sent characters (the solution there by Naveen Ravindra works). Edit these files:
trinidad-impl-XXX.jar\META-INF\adf\jsLibsDebug\xhr\XMLRequest.js
trinidad-impl-XXX.jar\META-INF\adf\jsLibs\xhr\XMLRequest.js
Add this new function to them (paste this to the beginning of the js:
function encodeCharacters(string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
for ( var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
}
Change the TrXMLRequest.prototype.send function in the same js. In it change
xmlhttp.send(content); to xmlhttp.send(encodeCharacters(content)); in the debug version, and
a4.send(a3); to a4.send(encodeCharacters(a3)); in the production version.
Tested, works in WAS 7.0.0.11.
Hi I can't reproduce your problem. Actually I don't get anything going if I try to program the jsp Page like you did. This is how my jsp's look like
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%# taglib uri="http://myfaces.apache.org/trinidad" prefix="tr" %>
<%# taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh" %>
<%# page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<f:view>
<tr:document>
<trh:head title="Your Title">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</trh:head>
</tr:document>
</f:view>
The tr:document, which you don't use creates a html, body and head tag.
You can use trh:head if you need it.
See trinidad's documentation:
Documentation tr:document
With this configuration I had no problem with an ó.
I have no PARAMETER_ENCODING set in web.xml and I am using jsf1.2 trinidad 1.2.14
This is not really an answer but it probably helps.
Regards
I've forgotten trinidad a bit, but in order for the button to affect the input text, dont you need a "partialTriggers" attribute set on the inputText component, which should have the ID of the button?
it is lkdg again
I tried to reproduce your issue.
jsp:
<tr:inputText
id="myfield"
value="#{myBean.myname}">
</tr:inputText>
<tr:commandButton
id="sayHello"
text="Say Hello"
partialSubmit="true"
action="#{myBean.sayHello}"/>
<tr:outputText
value="#{myBean.message}"
partialTriggers="sayHello"
inlineStyle="font-weight: bold;"/>
bean:
private String myname;
private String message;
public String sayHello()
{
message = "Hola " + myname;
return "";
}
public String getMyname() {
return myname;
}
public void setMyname(String myname) {
this.myname = myname;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
Everything works fine with ó and ễ and whatever.
jsf-1.2;trinidad1.2.14;apache tomcat6.0.29
I don't know the IBM WebSphere AS 7.0. But probably your problem has got something to do with what this guy is writing here: Displaying UTF-8 Characters in resource response
I am trying to implement menus in JSF which I was able to do it.
menucontents.jsp:
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%# taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8" />
<title>MyFaces - the free JSF Implementation</title>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/pages/css/basic.css" />
</head>
<body>
<f:view>
<f:loadBundle basename="com.cpc.resources.menu" var="menu"/>
<t:div id="hNav_outer">
<t:panelNavigation2 id="nav1" layout="list" itemClass="off" activeItemClass="on" openItemClass="on"
renderAll="true">
<t:commandNavigation2 value="#{menu['menu_Home']}" style="padding-left: 0px;">
<t:commandNavigation2>
<f:verbatim>› </f:verbatim>
<t:outputText value="#{menu['menu_Home']}"/>
</t:commandNavigation2>
</t:commandNavigation2>
<t:commandNavigation2 value="#{menu['menu_admin']}" style="padding-left: 150px;">
<t:commandNavigation2>
<f:verbatim>› </f:verbatim>
<t:outputText value="#{menu['menu_admin_change_password']}"/>
</t:commandNavigation2>
<t:commandNavigation2>
<f:verbatim>› </f:verbatim>
<t:outputText value="#{menu['menu_admin_forgot_password']}"/>
</t:commandNavigation2>
</t:commandNavigation2>
</t:panelNavigation2>
</t:div>
</f:view>
</body>
</html>
menu.jsp:
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%# taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8" />
<title>MyFaces - the free JSF Implementation</title>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/pages/css/basic.css" />
</head>
<body>
<f:view>
<f:subview id="headerinclude1">
<jsp:include page="menucontents.jsp" />
</f:subview>
</f:view>
</body>
</html>
I have tried various combinations i.e by removing the HTML / BODY / f:view tags but nothing seems to be working I know somewhere I am doing it wrong not able to check it. Any help would be appreciated.
Also, the first part of code when executed as an single file it works very well the only problem is when I include it in another JSP the menus are not getting displayed.
The <f:subview> has to go in the include file, not in the parent file. Replace the <f:view> in menucontents.jsp file by <f:subview> and remove the <f:subview> from the menu.jsp.
Summarized:
menu.jsp
<f:view>
<jsp:include page="menucontents.jsp" />
</f:view>
menucontents.jsp
<f:subview id="menucontents">
<f:loadBundle basename="com.cpc.resources.menu" var="menu"/>
...
</f:subview>
(note that the include file should not have a <f:view>, you also don't need a HTML head/body around it, that would only produce invalid HTML)