I re-targeted my project from wp8 to wp8.1. At first my package.appxmanifest file's build action was not set to Appxmanifest. Also it is only showing 4 tabs
-Application
-capabilities
-Declarations
-Packaging
Tabs that are missing are
-Visual Assets
-content URI's
-Declarations
What should i do.
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="37576f76-9ac9-4f78-b2d9-cb51446fb500" Publisher="CN=R" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="e4312153-3f4c-49dd-904d-5fbe8f1d6000" PhonePublisherId="3f72d71c-dd80-408e-affb-aa06372f300a" />
<Properties>
<DisplayName>app</DisplayName>
<PublisherDisplayName>app</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="xe4312153y3f4cy49ddy904dy5fbe8f1d6073x" Executable="AGHost.exe" EntryPoint="MainPage.xaml">
<m3:VisualElements DisplayName="app" Square150x150Logo="Assets\SquareTile150x150.png" Square44x44Logo="Assets\Logo.png" Description="app" ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
<m3:DefaultTile Square71x71Logo="Assets\SquareTile71x71.png">
</m3:DefaultTile>
<m3:SplashScreen Image="SplashScreenImage.jpg" />
<m3:ApplicationView MinWidth="width320" />
<!--Used in XAML Designer. DO NOT REMOVE-->
</m3:VisualElements>
</Application>
</Applications>
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>AgHostSvcs.dll</Path>
<ActivatableClass ActivatableClassId="AgHost.BackgroundTask" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
<Capabilities>
<Capability Name="internetClientServer" />
<DeviceCapability Name="location" />
</Capabilities>
</Package>
Silverlight-based apps don't have those extra tabs; they are only applicable to non-Silverlight (WinRT) apps. You set things like your Tile icons via the WMAppManifest.xml file.
I have an application implemented with JSF2 and Icefaces3 where I have problems in the stylesheets application. At the login the style sheet applies correctly, but after each redirection it's no longer correct. This problem is found only with IE browser. In the faces-config.xml file when I remove the redirect tag (), everything is ok except that the URL does not change and it does not take into account the tag: that I added to force compatibility mode. For the import of the stylesheet I have tried several formula:
<!-- formule 1-->
<ice:outputStyle
href="#{facesContext.externalContext.requestContextPath}/resources/css/global.css"
rel="stylesheet" type="text/css" />
<!-- formule 2-->
<ice:outputStyle
href="#{request.contextPath}/resources/css/global.css"
rel="stylesheet" type="text/css" />
<!-- formule 3-->
<ice:outputStyle
href="/resources/css/global.css"
rel="stylesheet" type="text/css" />
<!-- formule 4-->
<link href="#{facesContext.externalContext.requestContextPath}/resources/css/global.css" rel="styleSheet" type="text/css"/>
<!-- formule 5-->
<link href="#{request.contextPath}/resources/css/global.css" rel="styleSheet" type="text/css"/>
faces-config.xml :
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
<variable-resolver>org.springframework.web.jsf.SpringBeanVariableResolver</variable-resolver>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
<managed-bean>
<managed-bean-name>renderManager</managed-bean-name>
<managed-bean-class>com.icesoft.faces.async.render.RenderManager</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<factory>
<exception-handler-factory>
com.omb.exception.CustomExceptionHandlerFactory
</exception-handler-factory>
</factory>
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>homeHotel</from-outcome>
<to-view-id>/pages/home/home.xhtml</to-view-id>
<redirect />
</navigation-case>
<navigation-case>
<from-outcome>disconnect</from-outcome>
<to-view-id>/login.xhtml</to-view-id>
<redirect />
</navigation-case>
<navigation-case>
<from-outcome>error</from-outcome>
<to-view-id>/pages/errors/technicalError.xhtml</to-view-id>
<redirect />
</navigation-case>
<navigation-case>
<from-outcome>sessionExpired</from-outcome>
<to-view-id>login.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
web.xml :
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>MyApplication</display-name>
<description>MyApplication</description>
<!-- Without this param upload does not work at 1st time with IceFaces 3.3.0 -->
<context-param>
<param-name>org.icefaces.mandatoryResourceConfiguration</param-name>
<param-value>all</param-value>
</context-param>
<context-param>
<param-name>facelets.FACELETS_LIBRARIES</param-name>
<param-value>/pages/templates/tags.taglib.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/appCtx/**/*applicationContext*.xml
</param-value>
</context-param>
<!-- Facelet Config -->
<!-- <context-param> <param-name>javax.faces.application.CONFIG_FILES</param-name>
<param-value> /WEB-INF/faces-config-application-beans.xml, /WEB-INF/faces-config-navigation.xml
</param-value> </context-param> -->
<!-- <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value> </context-param> -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>-1</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.standardRequestScope</param-name>
<param-value>false</param-value>
</context-param>
<!-- Specifies to the ICEfaces framework whether to support multiple views
of a single application from the same browser. When running in a Portlet
environment, this parameter must be set to true. -->
<context-param>
<param-name>com.icesoft.faces.concurrentDOMViews</param-name>
<param-value>false</param-value>
</context-param>
<!-- Specifies to the ICEfaces framework that synchronous update mode is
to be used. By default, ICEfaces uses asynchronous update mode to support
server-initiated updates (AJAX push). Setting to true will enable synchronous
update mode and disable AJAX push features. -->
<context-param>
<param-name>com.icesoft.faces.synchronousUpdate</param-name>
<param-value>true</param-value>
</context-param>
<!-- Specifies to the ICEfaces framework whether to compress the server-side
DOM representation after each response. This saves a considerable amount
of of memory per client. However, since this is decompressed/compressed for
every update, it may not bring significant memory savings to applications
that make frequent use of AJAX push. -->
<context-param>
<param-name>com.icesoft.faces.compressDOM</param-name>
<param-value>true</param-value>
</context-param>
<!-- Specifies the amount of time in milliseconds that the bridge will wait
for a response from the server for a user-initiated request before declaring
the connection lost. Un-comment and change the default value, if necessary. -->
<context-param>
<param-name>com.icesoft.faces.connectionTimeout</param-name>
<param-value>300000</param-value>
</context-param>
<!-- Specifies the amount of time in milliseconds that an idle asynchronous
blocking connection should be held open before being released. Normally,
the blocking connection is closed and re-opened with every communication
to the browser, such as user interaction or a heartbeat ping. The purpose
of this setting is to remove the possibility of threads being held blocked
for a long duration on a dead or completely inactive client connection. This
value should be longer than the heartbeat interval to avoid unnecessary network
traffic. Un-comment and change the default value, if necessary. -->
<context-param>
<param-name>
com.icesoft.faces.blockingConnectionTimeout
</param-name>
<param-value>90000</param-value>
</context-param>
<!-- Specifies the amount of time in milliseconds between heartbeat messages.
Un-comment and change the default value, if necessary. -->
<context-param>
<param-name>com.icesoft.faces.heartbeatInterval</param-name>
<param-value>50000</param-value>
</context-param>
<!-- Specifies how many consecutive heartbeat connection attempts may fail
before the connection is considered lost. Un-comment and change the default
value, if necessary. -->
<context-param>
<param-name>com.icesoft.faces.heartbeatRetries</param-name>
<param-value>2</param-value>
</context-param>
<!-- Specifies the number of milliseconds that a heartbeat request waits
for a successful response before it is considered timed out. Un-comment and
change the default value, if necessary. -->
<context-param>
<param-name>com.icesoft.faces.heartbeatTimeout</param-name>
<param-value>60000</param-value>
</context-param>
<!-- Specifies a page URI to redirect the client to when an asynchronous
connection is lost. The parameter value must be surrounded by single quotes.
Un-comment and change the default value, if necessary. -->
<context-param>
<param-name>
com.icesoft.faces.connectionLostRedirectURI
</param-name>
<param-value>login.xhtml</param-value>
</context-param>
<context-param>
<param-name>
com.icesoft.faces.sessionExpiredRedirectURI
</param-name>
<param-value>login.xhtml</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.blockUIOnSubmit</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.icefaces.ace.fileEntry.requireJavascript</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<filter-name>springFilter</filter-name>
<filter-class>
org.springframework.web.filter.RequestContextFilter
</filter-class>
</filter>
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- <filter-mapping> <filter-name>loggedInFilter</filter-name> <url-pattern>/pages/*</url-pattern>
</filter-mapping> -->
<!-- SPRING -->
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.util.IntrospectorCleanupListener
</listener-class>
</listener>
<!-- Listener d'initialisation de l'application -->
<listener>
<listener-class>com.omb.listeners.MyServletContextListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/icefaces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<!-- Welcome files -->
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
<error-page>
<error-code>500</error-code>
<location>/pages/error.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.RuntimeException</exception-type>
<location>/pages/error.jsp</location>
</error-page>
</web-app>
login.xhtml :
<!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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<!-- ice:outputStyle href="/resources/css/global.css" rel="stylesheet"
type="text/css" /-->
<ice:outputStyle
href="#{facesContext.externalContext.requestContextPath}/resources/css/myCss.css"
rel="stylesheet" type="text/css" />
</h:head>
<h:body onload='document.getElementById("loginForm:login").focus()'>
<ice:form id="loginForm">
<h:panelGroup id="page" styleClass="mainMaster" layout="block">
<h:panelGroup id="header" styleClass="header" layout="block">
<h:panelGroup styleClass="logo" layout="block">
<ice:graphicImage styleClass="imgLogo"
value="/resources/images/common/logo/Logo.png" />
</h:panelGroup>
</h:panelGroup>
<h:panelGroup id="content" styleClass="mainContent" layout="block">
<h:panelGroup styleClass="content" layout="block">
<h:panelGroup styleClass="txtLogin" layout="block">
<span><ice:outputLabel value="#{msg['login']}" /> : * </span>
<ice:inputText value="#{loginBean.login}" id="login" />
</h:panelGroup>
<h:panelGroup styleClass="txtLogin" layout="block">
<span><ice:outputLabel value="#{msg['password']}" /> : *</span>
<ice:inputSecret value="#{loginBean.password}"
action="#{loginBean.doLogin}" />
<br />
<span></span>
</h:panelGroup>
<h:panelGroup styleClass="txtLogin" layout="block">
<span></span>
<ice:commandButton id="loginButton" value="#{msg['log.on']}"
action="#{loginBean.doLogin}" />
</h:panelGroup>
<h:panelGroup layout="block">
<ace:panel style="border: 0px;">
<ace:message id="formMsg" for="loginForm" initEffect="slide" />
</ace:panel>
</h:panelGroup>
</h:panelGroup>
</h:panelGroup>
<h:panelGroup id="footer" styleClass="footer" layout="block">
<ui:insert name="footer">
<ui:include src="/pages/layer/footer/footer.xhtml" />
</ui:insert>
</h:panelGroup>
</h:panelGroup>
</ice:form>
</h:body>
</html>
template.xhtml :
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title><ui:insert name="title">MyApplication</ui:insert></title>
<ice:outputStyle href="/xmlhttp/css/xp/xp.css" rel="stylesheet"
type="text/css" />
<!-- ice:outputStyle href="#{request.contextPath}/resources/css/global.css" rel="stylesheet" type="text/css" /-->
<ice:outputStyle
href="#{facesContext.externalContext.requestContextPath}/resources/css/global.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
jsf.ajax.addOnError(function(data) {
if (data.responseText.indexOf("SessionExpiredException") > 0) {
window.location = "login.xhtml";
}
});
// French initialization
ice.ace.locales['fr'] = {
closeText : 'Fermer',
prevText : 'Précédent',
nextText : 'Suivant',
currentText : 'Courant',
monthNames : [ 'Janvier', 'Février', 'Mars', 'Avril', 'Mai',
'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre',
'Novembre', 'Décembre' ],
monthNamesShort : [ 'Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun',
'Jul', 'Aoû', 'Sep', 'Oct', 'Nov', 'Déc' ],
dayNames : [ 'Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi',
'Vendredi', 'Samedi' ],
dayNamesShort : [ 'Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam' ],
dayNamesMin : [ 'Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa' ],
weekHeader : 'Sm',
dateFormat : 'dd/mm/yy',
firstDay : 1,
isRTL : false,
showMonthAfterYear : false,
yearSuffix : ''
};
</script>
</h:head>
<h:body>
<h:panelGroup id="page" styleClass="mainMaster" layout="block">
<h:panelGroup id="header" styleClass="header" layout="block">
<ui:insert name="header">
<ui:include
src="/pages/layer/header/#{contextBean.templateHeaderName}" />
</ui:insert>
</h:panelGroup>
<h:panelGroup id="headerMenu" styleClass="menu" layout="block">
<ui:insert name="buttons">
<ui:include
src="/pages/layer/menu/#{contextBean.templateMenuButtonName}" />
</ui:insert>
</h:panelGroup>
<h:panelGroup id="main" styleClass="mainContent" layout="block">
<h:panelGroup id="content" styleClass="content" layout="block">
<h:panelGroup layout="block"
rendered="#{not facesContext.validationFailed and not empty facesContext.messageList}">
<h:messages id="psuedoGlobalMessages" globalOnly="true"
infoStyle="color:blue" errorStyle="color:red"
warnClass="color:orange" showDetail="false" showSummary="true" />
</h:panelGroup>
<ui:insert name="content" />
</h:panelGroup>
</h:panelGroup>
<h:panelGroup id="footer" styleClass="footer" layout="block">
<ui:insert name="footer">
<ui:include src="/pages/layer/footer/footer.xhtml" />
</ui:insert>
</h:panelGroup>
</h:panelGroup>
</h:body>
</html>
I found the solution :
First I changed the implementation of the login.xhtml page so that it includes also in my Facelet template.
Second : I added the DOCTYPE balise at the beginning of the template.xhtml
Now the sheetstyle is applied in all pages.
For the compatibility mode i made a HttpFilter which set attribute :
((HttpServletResponse) response).setHeader("X-UA-Compatible", this.xuacompatible);
Im a Totally new in Java and JSF. I'm using eclipse Indigo and Tomcat 6.0.3 and JSF 2.0.
When i run the Page in Browser, I just get an empty page, but i could the elements in firebug that it is still in JSF tags itself. It is not rendering in html..
This is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>ContactFormJSF</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>pages/index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>*.xhtml</param-value>
</context-param>
<session-config>
<session-timeout>15</session-timeout>
</session-config>
</web-app>
This is my Basic JSF content
<?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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Add New User Form</title>
</h:head>
<h:body>
<f:view>
<h:form>
<h:panelGrid border="1" columns="3">
<h:outputText value="Name"></h:outputText>
<h:inputText value="#{userBean.name}" required="true"></h:inputText>
<h:outputText value="D.O.B"></h:outputText>
<h:inputText id="DOB" value="#{userBean.dob}" required="true"> </h:inputText>
<h:outputText value="Age"></h:outputText>
<h:inputText id="age" value="#{userBean.age}" required="true"> </h:inputText>
<h:commandButton action="#{userBean.addUser}" value="Submit"></h:commandButton>
<input type="reset"/>
<h:commandButton action="#{userBean.reset}" value="Reset"> </h:commandButton>
</h:panelGrid>
</h:form>
</f:view>
</h:body>
</html>
Iam Struggling for this for a week, I have tried out many things noted down in stackoverflow..
The URL iam using is localhost:8080/ContactFormJSF/
I could see the HTML tags which is added above in the Browser but not the jsf tags..
Actually, the FacesServlet mapping in your web.xml doesn't cover the .xhtml files, so you should add the proper mapping to the configuration file:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
In other side, you should retreive this to let the JSF controller recognize the .xhtml files in your project:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>*.xhtml</param-value>
</context-param>
I'm using atocompleter in my form with json.
This is the part of my struts.xml
<package name="json" namespace="/" extends="json-default">
<result-types>
<result-type name="json" class="com.googlecode.jsonplugin.JSONResult" />
</result-types>
<action name="test" class="testClass" method="populate">
<result type="json" name="success">
<param name="root">itemList</param>
<param name="contentType">text/html</param>
</result>
</action>
</package>
This is the jsp
<s:form id="frm_demo" name="frm_demo" theme="simple" action="test2">
<s:url id="remoteurl" action="test" />
<sj:autocompleter
id="lst"
name="lst"
list="%{remoteurl}"
listValue="name"
listKey="id"
selectBox="true"
/>
<s:submit value="submit"/>
</s:form>
This is the action class method
public String populate() throws Exception{
itemList.put("1", "a");
itemList.put("2", "b");
itemList.put("3", "c");
return "success";
}
With the above code in struts.xml my jsp renders like this.{"3":"c","2":"b","1":"a"}
But when I delete the "contentType" parameter, in other words the content type is "application/json" the jsp pops the download window.
I need theauto completer to return the key when i click submit button. But the page doesn't load with the autocompleter. Any solutions?
p.s. itemList i used in my action class is a HashMap... does that matter?
Using map is OK with collection-backed components. I think there's couple of problems with your code.
First in you action configuration you have set the root object to your itemList, this way only content of the list will be converted to json so you can't refer to the list itself in your autocompleter.
Second you have to set the href attribute for your autocompleter and set the remoteUrl as it's value. So your code could be like:
<package name="json" namespace="/" extends="json-default">
<action name="test" class="testClass" method="populate">
<result type="json"/>
</action>
</package>
In your autompleter:
<s:form id="frm_demo" theme="simple" action="test2">
<s:url id="remoteurl" action="test" />
<sj:autocompleter href="%{remoteurl}"
id="lst"
name="lst"
list="itemList"
listValue="name"
listKey="id"
selectBox="true"/>
<s:submit value="submit"/>
</s:form>
See if that works.
I think your code is ok,Just remove this code
<param name="contentType">text/html</param>
I am getting this exception when using struts 2 with tiles
org.apache.tiles.definition.NoSuchDefinitionException: /index.jsp
//tiles.xml
<tiles-definitions>
<definition name="baseLayout" template="/index.jsp">
<put-attribute name="title" value="/Template" />
<put-attribute name="header" value="/Header.jsp" />
<put-attribute name="menu" value="/Menu.jsp" />
<put-attribute name="body" value="/body.jsp" />
<put-attribute name="footer" value="/Footer.jsp" />
</definition>
<tiles-definitions>
//index.jsp
<%# taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<tiles:insertAttribute name="header"/>
<tiles:insertAttribute name="footer"/>
</body>
</html>
//web.xml
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.
DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
//struts.xml
<package name="default" namespace="/test" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="login" class="com.medics.action.LoginAction">
<result name="SUCCESS" type="tiles">/index.jsp</result>
</action>
</package>
I have searched a lot but found nothing
org.apache.tiles.definition.NoSuchDefinitionException: /index.jsp
Means that there is no tiles definition, that is no definition of the name "/index.jsp"
When using struts and tiles... Your request comes into struts then out to tiles where tiles composes the view so you shouldn't have any tiles definitions called "anything.jsp".
So just replace
<result name="SUCCESS" type="tiles">/index.jsp</result>
with
<result name="SUCCESS" type="tiles">baseLayout/result>
Now that is resolved... I would rename index.jsp, template.jsp (I think it's less confusing), why do you have a put-attribute called "/Template" ?
Now to fix the issue I recommended that you change the struts2 result target to "baseLayout" but this is probably not what you mean, so you probably want to use your baseLayout definition for new pages so add a new definition:
<definition name="index" extends="baseLayout">
<put-attribute name="title" value="My Title for Index" />
<put-attribute name="body" value="/index.jsp" />
</definition>
Now the above will take that value in defaultTemplate and add (or if the name is the same, override) what was in the base template creating a page for index.jsp, and now your struts.xml should have
<result name="SUCCESS" type="tiles">index</result>
I encountered this problem today.
Although it was a question long ago, I found the solution as below:
<result name="SUCCESS" type="dispatcher">/index.jsp</result>
Just replacing the type tiles with dispatcher works for me.