[JBoss Seam] - Re: Add operation specific pages.xml configuration
by wayfarer3130
Adding support for sub-operations also would allow better support for cache control, where the sub-operation might over-ride the parent's cache control, that is, the document might be cached by default for 9 seconds, by not at all for get operations with an op provided (this probably isn't realistic for this example, but for something like an editor or the like, it is very nice to have reasonable cache control built in.)
| <pages>
| <page view-id="/calculator.jsp" action="#{calculator.calculate}">
| <cache expires="9" />
| <param name="x" value="#{calculator.lhs}"/>
| <param name="y" value="#{calculator.rhs}"/>
| <param name="op" converter="#{operatorConverter}" value="#{calculator.op}"/>
| <view-modifier value="#{calculator.op}" />
| </page>
| <page view-id="/calculator.jsp" view-modifier="+" action="#{calculator.add}">
| <cache expires="0" />
| </page>
| <page view-id="/calculator.jsp" view-modifier="?:">
| <cache expires="0" />
| <param name="z" value="#{trivalued.z}" />
| </page>
| </pages>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049429#4049429
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049429
18 years, 10 months
[JBoss Seam] - Add operation specific pages.xml configuration
by wayfarer3130
The pages.xml file assumes that for a given view-id, all responses/updates
are handled identically. That isn't necessarily a good idea as it means that the
action is the same in all cases and that violates separation of concerns. In specific, the example in the tutorial:
| <page view-id="/calculator.jsp" action="#{calculator.calculate}">
| <param name="x" value="#{calculator.lhs}"/>
| <param name="y" value="#{calculator.rhs}"/>
| <param name="op" converter="#{operatorConverter}" value="#{calculator.op}"/>
| </page>
|
implies that calculator.calculate knows about EVERY op possible. In this example, it isn't possible to add a new operation without modifying calculator.calculate. Sometimes that is a good idea if there are a very few operations available, but if there are lots of operations, then calculator.calculate needs to have some sort of registration mechanism for new operations - however, consider the operation ?: that takes x,y,z. This operation won't work because the parsing doesn't work correctly. Or consider the hex conversion operation - again, the value is probably a double or integer or some such thing, and the parsing doesn't work for that either.
It would be helpful to have something like:
| <pages>
| <page view-id="/calculator.jsp" action="#{calculator.calculate}">
| <param name="x" value="#{calculator.lhs}"/>
| <param name="y" value="#{calculator.rhs}"/>
| <param name="op" converter="#{operatorConverter}" value="#{calculator.op}"/>
| <view-modifier value="#{calculator.op}" />
| </page>
| <page view-id="/calculator.jsp" view-modifier="+" action="#{calculator.add}" />
| <page view-id="/calculator.jsp" view-modifier="?:">
| <param name="z" value="#{trivalued.z}" />
| </page>
| </pages>
|
Note that this works fairly well with RESTful services - the post can be done to the same URL, but different actions can go through different operations, and then still render the same overall page.
It also works well if you want to add another outcome variant - just add a view modifier and add a new outcome.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049427#4049427
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049427
18 years, 10 months
[JBoss Seam] - Problem about EntityManager.
by grdzeli_kaci
hi all,
i updated my jboss application server to 4.2.0GA and also i got seam from CVS.
i tried to run simple seam-gen project,
everything works fine, but when i tried to use database level authentication i got an error like this :
| javax.el.ELException: org.jboss.seam.RequiredException: In attribute requires non-null value: authenticator.em
| at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
| at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:338)
| at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
| at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
| at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
| ..................................................................
| Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: authenticator.em
| at org.jboss.seam.Component.getValueToInject(Component.java:1923)
| at org.jboss.seam.Component.injectAttributes(Component.java:1372)
| at org.jboss.seam.Component.inject(Component.java:1203)
| at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
|
|
i did not understand why is this object is null :(
here is project snippets
1. Authenticator class:
|
| @Name("authenticator")
| public class Authenticator {
|
| @Logger Log log;
|
| @In Identity identity;
|
| @In() EntityManager em;
|
| public boolean authenticate() {
| try {
| log.info("authenticating = "+identity.getUsername());
| List<Users> users = (List<Users>)em.createNamedQuery("Users.findByUserName").setParameter("userName",identity.getUsername()).getResultList();
| if (users==null || (users!=null && users.isEmpty())) {
| FacesMessages.instance().add("User #{user.username} does not exists");
| return false;
| } else {
| for (Users user : users) {
| byte dbpaswd [] = user.getUserPwd();
| String strpwd = identity.getPassword();
| MessageDigest md5 = MessageDigest.getInstance("MD5");
| md5.reset();
| md5.update(strpwd.getBytes());
| byte[] userpasswd = md5.digest();
|
| boolean result = MessageDigest.isEqual(userpasswd, dbpaswd);
| if (result) {
| identity.addRole("admin");
| return true;
| }
| }
| }
| return false;
| } catch (Exception e) {
| FacesMessages.instance().add("Could not login. System Error");
| return false;
| }
| }
| }
|
2. Components.xml :
| <core:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/BillingEntityManagerFactory"/>
|
3. Billing-dev-ds.xml file :
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>BillingDatasource</jndi-name>
| <connection-url>jdbc:oracle:thin:@192.168.9.135:1521:DEVSTR</connection-url>
| <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
| <user-name>ccare</user-name>
| <password>ccare</password>
| </local-tx-datasource>
| </datasources>
|
4. Client logi.xhtml
| <h:commandButton id="loginBtn" value="Login" action="#{identity.login}"/>
|
what i did incorrect ?
is it possible that reason of it is i have not this jar files into my ear file ???
?commons-jci-core-1.0-406301.jar
?commons-jci-janino-2.4.3.jar
?commons-lang-2.1.jar
?stringtemplate-2.3b6.jar
this jars are described into documentation from where i got this example....
Regards,
Paata.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049426#4049426
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049426
18 years, 10 months