Table of Contents

FAQs

This list of Frequently Asked Questions should help to get you started with Studs and over many of the initial bumps. Also skim this list before reporting bugs because there is a good change we already know about your problem.

General

Where did the name Studs come from?

Well, at some point you have to pick a name for your project in order to publish it. Studs is somewhat of a play on project names and gets its inspiration from Struts. A strut is both an structural component and a swagger. In the same light, a stud is support post and an attractive person. So both names have a double meaning and it just seemed to fit.

I threw together a logo that shows the name carved out in wood, but it isn’t all the great. I would really like to have a logo that had a nail piercing a piece of wood, but I am artistically challenged.

My changes to the configuration aren’t being picked up! What do I do?

In order to optimize performance, the Stratus servlet container is initialized only once, after which time it is serialized/unserialized from disk on each page request. Caching this configuration object reduces overhead that is typically associated with PHP scripts. However, this also means that you have to do a little bit extra when you make changes to either web.xml or struts-config.xml.

To “restart” the application, simply remove the following file:

your_app/WEB-INF/work/ServletContext.ser

Note that changes to PSP files or the struts-config.xml file are detected automatically and does not require a container “restart”.

What are all those funny & symbols in the code?

An & symbol used in a variable assignment tells the PHP runtime to return a reference to the underlying object rather than making a copy. This is very important when you are working on a single instance of an object, which is necessary in many places in the framework. See the Object References page for an explanation of how this works and when to use it.

I am getting the error: Fatal error: Call to a member function ... on a non-object... What do I do?

Studs has worked through a slippery PHP road. The presence of this message is usually an indication of an API change in PHP that has broken Studs. This misleading exception happens because Studs is using a retrofitted exception handling framework that doesn’t always succeed at surfacing the underlying exception. Specifically, this message is generated during the classloading process, Clazz::forName, which bails out if there is a pending exception on the stack.

To make things a little easier, the exception is logged in the apache or php error log, so that is the first place to check. In many cases, the actual exception is pretty far away from the file mentioned in the fatal error.

Studs MVC

Do I need to populate my ActionForm class with values from the request?

No. This population is handled automatically by the controller. Please see Form Processing for more details on how the ActionForm instance is managed.

The html:messages taglib doesn’t find my messages. What is wrong?

The html:messages taglib looks for messages in the page scope by default. It is necessary to use the scope attribute and specify the value of request or session depending on where the messages were stored. ActionForm errors are always placed in the request. See the Studs HTML Taglib for details.

How do I prevent the “double submit” problem?

There are two ways to handle this problem using the Studs framework, which can also be used in combination. The generally accepted way to handle double form submits is to perform an HTTP redirect after a POST operation. (Add the redirect=”true” attribute to the action forward element in struts-config.xml). Redirecting makes the new target visible in the client’s browser, so a refresh would simple reload the target page. Without this redirect, the target would remain as the form action and the browser would attempt to resend the form data (usually prompting the user first). Another alternative is to use tokens, which mark each form with a unique signature that can be validated in the action handler that responds to the form submission. Details of token processing are included on the Action Handler page.

The variable I put in session scope is being dropped. What is happening to it?

Don’t fret, it isn’t gone. Rather, it is a quirk in PHP, for which Studs does offer a solution. If you don’t start the session on every request, then you cannot access variables in session scope. The PSP pages intentionally don’t start the session when looking for those session scoped variable so as to play nice. One workaround is to make a called to $request→getSession(true) in every action. However, this is obviously unnecessary baggage. An easier way is to use the startSession property of the controller (available in Studs >= 0.9.9), which will automatically start the session on each request handled by the RequestProcessor.

<controller>
  <set-property property="startSession" value="true" />
</controller>
 
faqs.txt · Last modified: 2006/12/31 06:55 by 69.255.155.127 (dallen)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki