Pustefix Frequently Asked Questions


Table of Contents

1. Installation
2. Configuration
3. XML and XSL
4. Pageflows
5. States
6. Handler and wrapper
7. AJAX

Chapter 1. Installation

1.1. I don't have access to DNS and I don't want to mess up my hosts file. Is there any other way to access a pustefix application?

1.1.

I don't have access to DNS and I don't want to mess up my hosts file. Is there any other way to access a pustefix application?

Yes but only if you have one application deployed on that server and you are just using tomcat, without apache. Pustefix uses a virtual host for every application deployed. However you can use the <serveralias/> option from the project.xml.in file. Let's say that the ip of the server is 111.222.333.444. You can use something like <serveralias>111.222.333.444</serveralias> then redeploy the application.

Now you can access your favourite pustefix application via http://111.222.333.444:8080/xml/config.

Chapter 2. Configuration

2.1. I need some custom java properties for my application. Where should I put them?

2.1.

I need some custom java properties for my application. Where should I put them?

You can add those in the <properties/> section of your servlet configuration file. For example at the end of your app.conf.xml you can have something like:

<properties>
  <prop name="jdbc_conn_string">jdbc:mysql://foo/bar</prop>
</properties>

Chapter 3. XML and XSL

3.1. Why doesn't <pfx:image/> find my images?
3.2. Can I see the runtime XML that is used in some particular page?
3.3. Can I see the generated xsl files?
3.4. Why does my submit button do nothing?
3.5. How is i18n achieved in a pustefix application?

3.1.

Why doesn't <pfx:image/> find my images?

If your project is named foo and your images are in foo/img then, in project.xml.in you should have something like <passthrough>foo/img</passthrough>. This is for Apache to generate the necessary alias lines so the requests are mapped correctly.

3.2.

Can I see the runtime XML that is used in some particular page?

Yes. While in development phase, you can use the <pfx:editconsole/> tag anywhere in your page. It will display a link which opens the editor and a link which shows the raw runtime XML used to generate the page.

3.3.

Can I see the generated xsl files?

Yes, they can be found in the projects/.cache directory.

3.4.

Why does my submit button do nothing?

Check if you have a <pfx:forminput> around it on the page.

3.5.

How is i18n achieved in a pustefix application?

You can achieve i18n by using something like

<part name="username">
  <theme name="default">
    <lang name="default">some text</lang>
    <lang name="de_DE">etwas text</lang>
  </theme>
</part>

and when you include this part in your page, the correct language will be selected at runtime by pustefix. To change the language, you can use the request parameter __language. For example requesting your page with __language=de will display the text under <lang name="de">. You can also change the language programatically using the setLanguage() method from the Context.

Chapter 4. Pageflows

4.1. The page that is specified as final must be declared as a flowstep in the pageflow that uses it?

4.1.

The page that is specified as final must be declared as a flowstep in the pageflow that uses it?

No, you can declare any arbitrary page as final, it doesn't have to be in the same pageflow where it is used.

Chapter 5. States

5.1. When I implement the getDocument() method of a State descending from StaticState, what is the difference between new Document() and super.getDocument(context, preq)?
5.2. What is the difference between StaticState and StateImpl?

5.1.

When I implement the getDocument() method of a State descending from StaticState, what is the difference between new Document() and super.getDocument(context, preq)?

If you use a new document, the pageflow will usually continue without displaying the page while if you use super.getDocument, the pageflow will stop on this page and on all the ContextResources that are declared in this pagerequest will be called insertStatus().

Basically, when using a new document, descending from StaticState doesn't really make sense, as you don't use anything interesting from this class - descending from StateImpl directly would be just as good.

5.2.

What is the difference between StaticState and StateImpl?

StateImpl is abstract and does not implement the getDocument() method. StaticState implements the getDocument() method, calls insertStatus of all the ContextResources defined for this pagerequest and stops the pageflow.

Chapter 6. Handler and wrapper

6.1. What is the prerequisitesMet(...) method used for and when is it called?
6.2. Can I reuse my existing iwrp interfaces?

6.1.

What is the prerequisitesMet(...) method used for and when is it called?

The prerequisitesMet() method from the IHandler interface is used by pustefix to determine which HTML links should be active or not. This method is called once per each request, on all IHandlers, from all pageflows. Thus, this method should be very fast or else the whole system would be slowed down.

6.2.

Can I reuse my existing iwrp interfaces?

Yes, you can extend an interface and add some more parameters to it or override older definitions, instead of writing a new one from scratch. You can also assign a new handler. Use the extends attribute of the <interface/> tag.

Chapter 7. AJAX

7.1. How do I switch my webservice from the SOAP to the JSON protocol?
7.2. How to make a asynchronous webservice call?
7.3. For what is requestID parameter in async-callback functions?
7.4. What are the different session types for in webservices.conf.xml?
7.5. How do I get access to the Context or Context Resources inside a webservice implementation?
7.6. Which libraries have to be added?
7.7. How to load multiple generated JSON stubs in a single file, within a single request?

7.1.

How do I switch my webservice from the SOAP to the JSON protocol?

You just have to exchange some Javascript libraries. The stub implementations are compatible, so you don't have to modify your Javascript code.

Replace the SOAP libraries

<script type="text/javascript" src="/core/script/xmlRequest.js"></script>
<script type="text/javascript" src="/core/script/webservice.js"></script>
<script type="text/javascript" src="/xml/wsscript/MyService.js"></script>

by the according JSON libraries (the build-time generated stub is replaced by its dynamic counterpart using the pfx:wsscript tag)

<script type="text/javascript" src="/core/script/httpRequest.js"></script>
<script type="text/javascript" src="/core/script/webservice_json.js"></script>
<pfx:wsscript name="MyService"/>

7.2.

How to make a asynchronous webservice call?

Simply add, as an additional parameter, a function reference to the call of the appropriate webservice-object's method call:

webserviceObject.getRemoteSearchResult(queryString, callbackFunction);

Or create the webservice with an object reference as argument (whose methods will be called back automatically):

var search={
   getRemoteSearchResult: function(result,requestid,exception) {
      ...
   }
}
var service=new WS_SearchService(search);
service.getRemoteSearchResult(queryString);

7.3.

For what is requestID parameter in async-callback functions?

While synchronous calls are blocking and only can be made sequentially, asynchronous calls can be made simultaneously and they can return in undetermined order. Using a requestID the application can control or manage the order of the returning calls.

7.4.

What are the different session types for in webservices.conf.xml?

The session type servlet indicates that the service request needs a valid Pustefix/HTTP session (webservices which need to access ContextResources have to be of this type). Type none indicates that the service needs no session.

7.5.

How do I get access to the Context or Context Resources inside a webservice implementation?

A webservice gets access to the Context or ContextResources by deriving from de.schlund.pfixcore.webservice.AbstractService and thus inheriting its access methods getContext() and getContextResource().

7.6.

Which libraries have to be added?

None. All necessary libraries come bundled with Pustefix.

7.7.

How to load multiple generated JSON stubs in a single file, within a single request?

Using pfx:wsscript you can request multiple stubs by specifying the servicenames as a whitespace-separated list.

<pfx:wsscript name="service1 service2 service3"/>
[Warning]Be careful with the SOAP client

Never include the SOAP implementation code twice on a page! leads to strange "serializer not found exception"