how to access xhtml file from jar file - jsf-2

I am working with jsf 2.0 project. i want to access xhtml file from jar file. in jar file i putted three files first.html, second.xhtml, h1.jpg. i can access jpg and html file from jar using following url.
<h:graphicImage url="#{resource['h1.jpg']}"/>
<h:outputLink value="#{resource['first.html']}">
<h:outputText value="OutputLink"/>
</h:outputLink>}
but i cant access xhtml from jar using following urls.
<h:outputLink value="#{resource['second.xhtml']}">
<h:outputText value="OutputLink"/>
</h:outputLink>
<h:outputLink value="#{resource['second.jsf']}">
<h:outputText value="OutputLink"/>
</h:outputLink>}
it is giving source not found error.
my jar structure is jar:META-INF/resources

A XHTML (Facelet) file is not a resource. Just reference it the usual way.
<h:outputLink value="second.xhtml">OutputLink</h:outputLink>
or
<h:link value="OutputLink" outcome="second" />

I've been having the same issue for the past few days. I tried a bunch of things and what finally worked for me was changing the top of my web.xml to:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
Hope that works for you.

Related

attaching #Entity annotations to jaxb-generated classes from a wsdl

My goal is to add #Entity annotations to the classes that are generated from a wsdl. I'm using cxf-codegen-plugin's wsdl2java goal, and pointing at a local wsdl file. I can generate all the sources without any problem, but when I try to add a binding file, I'm running into problems.
Here's a segment of the wsdl (the file is CAAudit.wsdl and is in my resources directory):
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://www.ocse.gov/quick/wsdl/CAAudit.wsdl"
xmlns:audw="http://www.ocse.gov/quick/wsdl/CAAudit.wsdl"
xmlns:audx="http://www.ocse.gov/quick/wsdl/CAAudit.xsd"
xmlns:qikrsp="urn:us:gov:hhs:acf:qikrsp"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
name="CAAudit"
>
<wsdl:types>
<xsd:schema targetNamespace="http://www.ocse.gov/quick/wsdl/CAAudit.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<xsd:import namespace="urn:us:gov:hhs:acf:qikrsp"
schemaLocation="QuickResponse.xsd" />
<xsd:complexType name="NotifyCAAuditRequest" >
<xsd:sequence>
<xsd:element ref="qikrsp:QuickResponse" />
</xsd:sequence>
</xsd:complexType>
....
My first question is I'm really not certain what should go in the binding file. First, I'm pretty sure that I need jaxws bindings to work with the wsdl (the jaxb binding only has the schemaLocation attribute), although I don't need to generate web service classes.
Next, I'm not sure I'm not sure if the introduction of a new xmlns in the schema element will cause problems for an xpath search. I did have problems running it with notepad++'s xpath evaluation.
Also, I'm not sure if the fact that the QuickResponse element (which is the class I want to annotate) is defined by a reference is hindering my efforts. I'm not sure if or how (or where) I would include the referenced xsd file.
Here is one possible binding file (I was just trying to get an #Generated on the class to start with):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionBindingPrefixes="annox"
jaxb:version="2.1"
>
<jaxws:bindings wsdlLocation="CAAudit.wsdl"
node="/wsdl:definitions/wsdl:types">
<jaxb:bindings node=".//xsd:schema">
<annox:annotate>#javax.annotation.Generated({"JAXWS"})</annox:annotate>
</jaxb:bindings>
</jaxws:bindings>
</jaxb:bindings>
I did not manage to customize schema embedded in WSDL. This are my latest efforts:
https://github.com/highsource/jaxb2-annotate-plugin/blob/master/tests/jaxws/src/main/resources/wsdl-bindings.xjb
What works with WSDLs is attaching customizations via SCD. But SCD does not allow proprietary customization elements (like annotate:*). So that won't help with jaxb2-annotate-plugin.
So the only thing which would probably work is to extract schema from the WSDL into an own file.

Using Servicestack WSDL with php

I am trying to use ServiceStack to replace WCF for a self hosted service, accessed with a PHP client that forms its messages from on the WSDL.
The WSDL produced by ServiceStack has "part names" called "par" eg:
<wsdl:message name="GetServiceDetailsIn">
<wsdl:part name="par" element="tns:GetServiceDetails" />
</wsdl:message>
Then the SOAP request produced by PHP looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body><par/></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
instead of this from the built-in help:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetServiceDetails xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:Shout" />
</soap:Body>
</soap:Envelope>
The PHP client has used a par tag instead of GetServiceDetails and it gets a blank response. Can the "part name" definition can be renamed or removed in ServiceStack?
It seems you can't doing anything about this in ServiceStack and its not designed to work with PHP anyway. However you can get it working if you get PHP to tweak the XML tags with find-and-replace, or XSLTs, before sending it.

Facelet Method call where property required

Is it possible to invoke a method where property is expected in JSF 2.0 Facelet EL. For example:
<h:outputText value="#{pojo.methodName}" />
where pojo is an instance of POJO and methodName is the name of method. An error would be thrown because JSF expects to find getMethodName method.
Before someone asks why one would need this, consider any value we want to display in text which is computed and we don't have required getter method and no source code.
Update after BalusC Answer:
No rename possible because no source code available. methodName() didn't work. The only difference is that in actual code its chained pojo.
<h:outputText value="#{pojo1.pojo2.methodName()}" />
Since other properties are working for pojo2, I assume that its methodName which can not be invoked. Server says "The class does not have the property methodName"
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
Empty faces-config
<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">
</faces-config>
P.S. environment JBoss 6 and JSF 2
Add parentheses:
<h:outputText value="#{pojo.methodName()}" />
(which only works in EL 2.2, which is part of Java EE 6, so it only works out box in Tomcat 7, Glassfish 3, etc, see also Invoke direct methods or methods with arguments / variables / parameters in EL)
Or just rename the method:
public String getMethodName() {
// ...
}

JSF2.0: EL are not resolved in a Composite Component taglib

I'm trying to create a custom composite component taglib in my office but i get a strange issue with EL. It seems expressions as #{cc.attrs.[var] } are already resolve as empty.
I try to create my taglib in a jar. In my jar i have my files ordered as following:
|_ /
.....|_ META-INF
..........|_ compo.taglib.xml
..........|_ resources
...............|_ components
....................|_ hello.xhtml
compo.taglib.xml contains:
<facelet-taglib 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-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://www.example.com/jsf/compo</namespace>
<composite-library-name>compo</composite-library-name>
<tag>
<tag-name>hello</tag-name>
<source>./components/hello.xhtml</source>
</tag>
</facelet-taglib>
hello.xhtml contains:
<?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:composite="http://java.sun.com/jsf/composite">
<composite:interface name="hello" displayName="hello">
<composite:attribute name="name" required="true" type="String"/>
</composite:interface>
<composite:implementation >
hello #{cc.attrs.name}!
</composite:implementation>
</html>
My web project contains in WEB-INF lib my taglib as a jar, jsf-impl.jar and jsf-api.jar (from Mojarra) my page is simply that:
<?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:comp="http://www.example.com/jsf/compo" >
<body>
<comp:hello name="John"></comp:hello>
</body>
</html>
At rendering i see "hello !" but not "hello John!". Attributes values seems be lost somewhere. I try this sample on tomcat 6.0.29 and Websphere 7.
I made something wrong?
Have you tested your control in web application rather than from taglib (jar file)?
I can only guess but I think your attribute is not showing because you named it name. In some cases "name" attribute is beeing used by JSF (for example in f:attribute or f:param or even ui:param uses attribute name). Try to replace attribute name with oder word.
You need to look here and check if attribute name is available.
Yes this case appears also with other attributes.
I tried with the component in web application and issue doesn't appear.
I also tried with the component in a jar with default namespace: issue doesn't appear. I think there is bug when using composite component in a jar with custom namespace.

Delphi 2007 isn't generating the XML I want to send to my Java-WS web service

I have a Java web service to which I've linked from a Delphi 2007 app using the WSDL Importer. Setting it up has been a rocky road but I'm almost there!
I now have the situation where my arrays aren't being serialized in a way that my Java web service can consume. I've written the same app in .Net to test it out (it works fine) and the XML I'm looking to generate looks like this: -
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body xmlns:NS2="http://path.to.service">
<NS1:addActivities xmlns:NS1="http://path.to.service/">
<login href="#1"/>
<project xsi:type="xsd:string">PROJ001</project>
<activities>
<id xsi:type="xsd:string">DELPHITEST</id>
<name xsi:type="xsd:string">This is a test</name>
</activities>
<activities>
<id xsi:type="xsd:string">DELPHITEST2</id>
<name xsi:type="xsd:string">This is another test</name>
</activities>
</NS1:addActivities>
<NS2:login id="1" xsi:type="NS2:login">
<database xsi:type="xsd:string">My_database</database>
<password xsi:type="xsd:string">neverUmind</password>
<username xsi:type="xsd:string">bob</username>
</NS2:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
However, the XML that Delphi generates is as follows: -
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body xmlns:NS2="http://path.to.service/">
<NS1:addActivities xmlns:NS1="http://path.to.service/">
<login href="#1"/>
<project xsi:type="xsd:string">PROJ001</project>
<activities xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="NS2:activity[2]">
<item href="#2"/>
<item href="#3"/>
</activities>
</NS1:addActivities>
<NS2:login id="1" xsi:type="NS2:login">
<database xsi:type="xsd:string">My_database</database>
<password xsi:type="xsd:string">neverUmind</password>
<username xsi:type="xsd:string">bob</username>
</NS2:login>
<NS2:activity id="2" xsi:type="NS2:activity">
<id xsi:type="xsd:string">DELPHITEST</id>
<name xsi:type="xsd:string">This is a test</name>
</NS2:activity>
<NS2:activity id="3" xsi:type="NS2:activity">
<id xsi:type="xsd:string">DELPHITEST2</id>
<name xsi:type="xsd:string">This is another test</name>
</NS2:activity>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Basically, I need Delphi to stop creating activity elements within the activities element and instead just put each ID and Name inside the an activities element (as .Net does and Java seems to expect).
I've buggered about with the InvRegistry.RegisterInvokeOptions and the RemClassRegistry.RegisterSerializeOptions but none of the combinations seem to work. To be honest I'm on the verge of writting my own XML parser for this as it's taking way to long to figure out. However, if anyone has any suggestions on how this should work I'd be very grateful.
Surely somebody out there must have consumed a Java-WS web service via Delphi 2007 before :)
TIA
It seems the XMLDocument component in Delphi 2007 is broken. I've installed the Alcinoe component instead and that works a charm. That was only a week wasted ... grrrr

Resources