Hello Everyone,
I'm using Trinidad to build a website for mobile devices. I'm using
Trinidad 2.0.0 on top of MyFaces 2.0.5, running on Tomcat 6.
This works out great for recent phones (and browsers), e.g. iPhones.
Unfortunately it seems that Trinidad puts a lot of other phones in
BasicHTML mode, too. I've found that UserAgents for Nokia, LG, Symbian,
SonyEricsson, and a lot more are recognized as "generic" devices (see
class AgentFactoryImpl in trinidad-impl). This alone wouldn't be that
much of a problem, but I can't seem to get BasicHTML to work either.
Normally, I use the action attribute on a tr:commandButton to call a
method of the bean":
--------------------------------------------------------------------------------
<tr:form id="loginForm">
<tr:inputText id="myUsername" value="#{loginBean.username}"
required="true" label="Username" />
<tr:inputText id="myPassword" value="#{loginBean.password}"
required="true" label="Password" />
<tr:commandButton id="myLoginButton" text="Log Me In"
action="#{loginBean.submit}" />
</tr:form>
--------------------------------------------------------------------------------
The submit method takes care of checking the credentials against the
back-end (database), and redirects the user to another page.
--------------------------------------------------------------------------------
@ManagedBean(name= "loginBean")
@RequestScoped
public class LoginBean {
private String fUsername;
private String fPassword;
// omitted getter/setter for these two fields
public String submit() {
String returnPath= "login";
try {
boolean success= getApi().authenticate(fUsername, fPassword);
if (!success) {
ErrorUtils.handleError("loginError"));
} else {
returnPath= "memberArea";
}
}
return returnPath;
}
}
--------------------------------------------------------------------------------
If Javascript is enabled, this works just fine: I click the submit
button, the submit() method is called, I'm redirected to the member area.
When using a browser that is recognized as "BasicHTML only", e.g.
OperaMini (or modifying the UserAgent string), the page is (correctly)
rendered without Javascript - but now my "submit()" method is not called
anymore - the page just reloads if I press the login button. Debugging
shows me that in this "reloaded" page's EventPhase, the submit method
isn't called - the event queue is empty). The page's source code shows
that the action-attribute of the <form> tag is set to "/login.xhtml"
(the name of my login page), i.e. the form is POST'ed back to itsself.
My questions are:
- Why are that many phones/browsers only supported as generic devices?
- Shouldn't BasicHTML mode work out-of-the box? I.e. if it works with
JS, it should work without?
- Do I need to explicitly catch the POST request in Non-JS mode? If so,
how can I do that, and how do I discern between validation error
messages (that go back to the same page, too) and the "real" request?
- Is there a way to disable Non-JS mode completely (I can live with
requiring JS for my users)? Can I force a render-mode that uses JS for
all browsers (even if I'd have to patch the library)?
Regards,
Beat
--
Beat Herlig, MSc CS ETH, Software Engineer
Comerge AG, Bubenbergstrasse 11, CH-8045 Zurich, www.comerge.net