I am trying to show a List. But nothing is displayed.
I used this tutorial:
http://www.roseindia.net/struts/struts2/struts2controltags/iterator-tag.shtml
but actually it is not working
Does anybody sees an error in this tutorial?
edit:
Thats ShowKeywords.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%#taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>Iterator Tag Example!</title>
</head>
<body>
<h1><span style="background-color: #FFFFcc">Iterator Tag Example!</span></h1>
<s:iterator value="myList" status="myListStatus">
<s:property /><br>
</s:iterator>
</body>
</html>
Struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- mapping of global-results and global-exceptions -->
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<constant name="struts.devMode" value="false"/>
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<default-action-ref name="Start"/>
<action name="ShowTest" class="de.nordakademie.librarymgmt.action.ShowTest">
<result>showKeywords</result>
</action>
</package>
</package>
</struts>
tiles
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="main" template="/jsp/main.jsp">
<put-attribute name="title" value="Dashboard"/>
<put-attribute name="menu" value="/jsp/menu.jsp"/>
<put-attribute name="header" value="/jsp/header.jsp"/>
<put-attribute name="content" value="/jsp/start.jsp"/>
</definition>
<definition name="showKeywords" extends="main">
<put-attribute name="title" value="Stichworte anzeigen"/>
<put-attribute name="content" value="/jsp/ShowKeywords.jsp"/>
</definition>
</tiles-definitions>
action ShowTest
package de.nordakademie.librarymgmt.action;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
public class ShowTest extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private List<String> myList;
public String execute()throws Exception{
myList = new ArrayList<String>();
myList.add("Fruits");
myList.add("Apple");
myList.add("Mango");
myList.add("Orange");
myList.add("Pine Apple");
return SUCCESS;
}
public List<String> getMyList(){
return myList;
}
}
</package> is closed twice in struts.xml (a well-indented code would have immediately shown that);
you are returning a standard result, not a Tiles result; put default="true" in your result definition:
<result-type name="tiles"
default="true"
class="org.apache.struts2.views.tiles.TilesResult" />
2.0 DTD is old, update it with the correct DTD.
Ensure you have all the libraries needed and that they're the right versions.
Related
I have a warning highlighted for the element:
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="localSystemServices" />
<rescap:Capability Name="packagedServices" />
</Capabilities>
With the below detail:
The element 'Capabilities' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' has invalid
child element 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities'. List of possible elements
expected: 'CapabilityChoice' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as
'Capability' in namespace 'http://schemas.microsoft.com/appx/manifest/uap/windows10' as well as 'Capability' in
namespace 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/4' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/6' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/7' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/3' as well as 'Capability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/2' as well as 'CustomCapabilityChoice' in namespace
'http://schemas.microsoft.com/appx/manifest/foundation/windows10' as well as 'CustomCapability' in namespace
'http://schemas.microsoft.com/appx/manifest/uap/windows10/4' as well as 'Dev....
The Package.appmanifest xml manifest is below:
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:desktop2="http://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
IgnorableNamespaces="uap rescap">
<Identity
Name="11d14331-0000-0000-0000-3c2e4cc6d69d"
Publisher="CN=my.name"
Version="1.0.10.0" />
<Properties>
<DisplayName>My Agent</DisplayName>
<PublisherDisplayName>My</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="My Agent"
Description="My Agent."
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<desktop6:Extension Category="windows.service" EntryPoint="Windows.FullTrustApplication" Executable="Agent\Agent.exe">
<desktop6:Service Name="Agent" StartAccount="localSystem" StartupType="auto"/>
</desktop6:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="localSystemServices" />
<rescap:Capability Name="packagedServices" />
</Capabilities>
<Extensions>
<desktop2:Extension Category="windows.firewallRules">
<desktop2:FirewallRules Executable="Agent\Agent.exe">
<desktop2:Rule Direction="in" IPProtocol="TCP" Profile="all"/>
<desktop2:Rule Direction="in" IPProtocol="UDP"
Profile="all"/>
<desktop2:Rule Direction="out"
IPProtocol="TCP"
Profile="all"/>
<desktop2:Rule Direction="out"
IPProtocol="UDP"
Profile="all"/>
</desktop2:FirewallRules>
</desktop2:Extension>
</Extensions>
</Package>
I'm using TFS OData service to create work item which is work fine. now i need to get id of work item and insert into database for later reference can anyone guide me direction for this ?
here is what i get as a response.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="https://tfsodata.visualstudio.com/DefaultCollection/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:etag="W/"datetime'2013-08-31T10%3A23%3A21.1439028%2B00%3A00'"" xmlns="http://www.w3.org/2005/Atom">
<id>https://tfsodata.visualstudio.com/DefaultCollection/WorkItems(0)</id>
<title type="text">my test work item</title>
<summary type="text">test work item created by isuru http://www.google.com</summary>
<updated>2013-08-31T10:23:21Z</updated>
<author>
<name />
</author>
<link rel="edit" title="WorkItem" href="WorkItems(0)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="WorkItems(0)/Attachments" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Links" type="application/atom+xml;type=feed" title="Links" href="WorkItems(0)/Links" />
<category term="Microsoft.Samples.DPE.ODataTFS.Model.Entities.WorkItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">0</d:Id>
<d:Project>My Website</d:Project>
<d:Type>Product Backlog Item</d:Type>
<d:WebEditorUrl m:null="true" />
<d:AreaPath m:null="true" />
<d:IterationPath m:null="true" />
<d:Revision m:type="Edm.Int32">0</d:Revision>
<d:Priority m:null="true" />
<d:Severity m:null="true" />
<d:StackRank m:type="Edm.Double">0</d:StackRank>
<d:AssignedTo m:null="true" />
<d:CreatedDate m:type="Edm.DateTime">2013-08-31T10:23:21.1419032+00:00</d:CreatedDate>
<d:CreatedBy m:null="true" />
<d:ChangedDate m:type="Edm.DateTime">2013-08-31T10:23:21.1439028+00:00</d:ChangedDate>
<d:ChangedBy m:null="true" />
<d:ResolvedBy m:null="true" />
<d:Title>my test work item</d:Title>
<d:State m:null="true" />
<d:Reason m:null="true" />
<d:CompletedWork m:type="Edm.Double">0</d:CompletedWork>
<d:RemainingWork m:type="Edm.Double">0</d:RemainingWork>
<d:Description>test work item created by isuru http://www.google.com</d:Description>
<d:ReproSteps m:null="true" />
<d:FoundInBuild m:null="true" />
<d:IntegratedInBuild m:null="true" />
<d:AttachedFileCount m:type="Edm.Int32">0</d:AttachedFileCount>
<d:HyperLinkCount m:type="Edm.Int32">0</d:HyperLinkCount>
<d:RelatedLinkCount m:type="Edm.Int32">0</d:RelatedLinkCount>
<d:Risk m:null="true" />
<d:StoryPoints m:type="Edm.Double">0</d:StoryPoints>
<d:OriginalEstimate m:type="Edm.Double">0</d:OriginalEstimate>
<d:BacklogPriority m:type="Edm.Double">0</d:BacklogPriority>
<d:BusinessValue m:type="Edm.Int32">0</d:BusinessValue>
<d:Effort m:type="Edm.Double">0</d:Effort>
<d:Blocked m:null="true" />
<d:Size m:type="Edm.Double">0</d:Size>
</m:properties>
</content>
</entry>
What I did was adding a Guid to a random field that you are not using and query for that Guid afterwards.
wi.Title = "New Work Item";
wi.FoundInBuild = Guid.NewGuid().ToString();
wi.Type = "Bug";
wi.Project = "TestProject";
context.AddToWorkItems(wi);
context.SaveChanges();
Debug.WriteLine(String.Format("Work item created"));
var createdWi = context.WorkItems.Where( d => d.FoundInBuild == wi.FoundInBuild);
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<MasterDetailsResponse xmlns="http://192.168.100.173/ArvindMill/">
<MasterDetailsResult>
<GetAllMasterDetail>
<TABLENAME>item_master</TABLENAME>
<ITEMID>1</ITEMID>
<ITEMTYPE>CTS</ITEMTYPE>
<GROUP />
<VARIETY />
<FORM />
<STATUS />
<ITEM />
<GRADE />
<TYPE />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>item_master</TABLENAME>
<ITEMID>2</ITEMID>
<ITEMTYPE>AGS</ITEMTYPE>
<GROUP /><VARIETY />
<FORM />
<STATUS />
<ITEM />
<GRADE />
<TYPE />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Anturli</VILLAGE>
<TALUKA>Anturli</TALUKA>
<TABLETUSERCODE />
<TABLETUSERNAME /><TABLETCODE />
<TABLETTALUKAID />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Bortha</VILLAGE>
<TALUKA>Sadgavan</TALUKA>
<TABLETUSERCODE /><TABLETUSERNAME />
<TABLETCODE />
<TABLETTALUKAID /></GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Kukarmunda</VILLAGE>
<TALUKA>Kukarmunda</TALUKA>
<TABLETUSERCODE />
<TABLETUSERNAME /><TABLETCODE /><TABLETTALUKAID />
</GetAllMasterDetail>
The above code is the response returned from soapobject in android. How to retrieve the data from the above XML file? I want to display it in list view and the response returned from the soapobject contains more than one table so how to retrieve it?
If your are using Java use SAX Parser
I'm trying to validate a form using the Struts2 validator tool but it doesn't seem to work since, apparently, the xml validator is never acknowledged.
Here is my code:
struts.xml:
<interceptors>
<interceptor name="login_interceptor" class="org.apache.struts.gesprod.produccion.BLLogin">
</interceptor>
<interceptor-stack name="login_stack">
<interceptor-ref name="login_interceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="login_stack"></default-interceptor-ref>
<global-results>
<result name="input">/errores/error_input.jsp</result>
<result name="error_sql">/errores/error_sql.jsp</result>
<result name="no_logged">/login.jsp</result>
</global-results>
...
<action name="login" class="org.apache.struts.gesprod.produccion.BLUsuario" method="loginUsuario">
<result name="success" type="redirect">/welcome.jsp</result>
<result name="incorrecto_login">/login.jsp</result>
<result name="input">/login.jsp</result>
</action>
login.jsp:
<div id="login">
<s:fielderror />
<s:form id="login_form" action="login" validate="true">
<s:hidden name="intento_log" value="true" />
<s:textfield name="usuario.username_usuario" label="Usuario"/>
<s:password name="usuario.password_usuario" label="Password"/>
<s:submit value="Ingresar"/>
</s:form>
</div>
And the xml validator, placed in the same package as the Action class.
BLUsuario-login-validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
<field name="usuario.username_usuario">
<field-validator type="requiredstring">
<message>Show error!</message>
</field-validator>
</field>
</validators>
Can somebody help and notice if there's something wrong with my code?
I think that the problem is in the name of the xml validator. You have to rename the validator with login-validation.xml. The name that you can put to your xml validator files are:
Validation rules can be specified:
Per Action class: in a file named ActionName-validation.xml
Per Action alias: in a file named ActionName-alias-validation.xml
Inheritance hierarchy and interfaces implemented by Action class: XWork searches up the inheritance tree of the action to find default validations for parent classes of the Action and interfaces implemented
You can see more here:
http://struts.apache.org/2.0.12/docs/validation.html#Validation-DefiningValidationRules
P.D: You said that "the "input" result is never returned even if the fields are wrong". The input result is returned if there are any field error (unless you specify other thing).
My struts.xml is under 'src' and action class is in a package 'login'.
Here's my struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="example" extends="json-default">
<action name="login" class="login.LoginAction">
<result type="json"/>
</action>
</package>
</struts>
My jsp(It is under /LoginEx/WebContent/Login.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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%# taglib prefix="s" uri="/struts-tags" %>
</head>
<body>
<s:form action="login.action" method="post" validate="true">
<s:textfield label="User Id" name="userId"></s:textfield>
<s:password name="password" label="Password"></s:password>
<s:submit value="Login"></s:submit>
</s:form>
</body>
</html>
The execute method in the action class:
public String execute(){
JSONObject json = new JSONObject();
json.put("success", "true");
return Action.SUCCESS;
}
When I try to run the appn, I get the error "There is no Action mapped for namespace / and action name login".
Could some1 plz help me out here. What am I doing wrong?
Here's the stack trace:
Here's the stack trace:
WARNING: Could not find action or result
There is no Action mapped for namespace / and action name login. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
ok ppl, I found out why I was getting this error. I was getting a warning: Unable to find parent packages json-default because I had just added the json-lib-2.2.2-jdk15.jar in lib and I didn't know that jsonplugin-0.32.jar was to be added as well.
I'm also now returning the json object from the action class as json.toString()
Thanks for the comments.