[JBoss Seam] - Re: lost parameter after login/forwarding
by henrik.lindberg
Duh...
| @Name("searchService")
| public class SearchService
| {
| @In(create=true)
| private EntityManager entityManager;
|
| private String m_searchPattern;
|
| @SuppressWarnings("unchecked")
| @Factory("searchResults")
| @Restrict("#{s:hasRole('user')}") // Forces check that user is logged in
| public List<InfoDigest> getSearchResults()
| {
| if(m_searchPattern == null)
| {
| return null;
| }
| /* TODO replace with proper search */
| return entityManager.createQuery("select i from MockData i where lower(i.name) like :searchPattern or lower(i.digest) like :searchPattern order by i.name")
| .setParameter( "searchPattern", getSqlSearchPattern() )
| .setMaxResults(100)
| .getResultList();
| }
|
| /**
| * Turn a typical search patter using * for wildcard, and ? for single character
| * into the SQL versions (% and _) of the same. Also addes SQL wildcard in the beginning and end
| */
| private String getSqlSearchPattern()
| {
| return m_searchPattern == null ? "" : '%' + m_searchPattern.toLowerCase().replace('*', '%').replace('?', '_') + '%';
| }
|
| public String getSearchPattern()
| {
| return m_searchPattern;
| }
|
| public void setSearchPattern(String searchPattern)
| {
| m_searchPattern = searchPattern;
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031847#4031847
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031847
19Â years
[JBoss Seam] - How to link to page using level of indirection
by henrik.lindberg
Hi, I currently have this:
| <h:outputLink value="object-view.seam">
| <f:param name="oid" value="#{x.id}"/>
| <h:outputText value="#{x.name}" />
| </h:outputLink>
|
to go to a detailed view of the object when clicked on the link.
I want to be able to call a method to determine which view to go to depending on the Class of x.
Essentially what I would want to do is write:
| <h:outputLink value="#{myViewSelector.selectViewFor(x)}">
| <f:param name="oid" value="#{x.id}"/>
| <h:outputText value="#{x.name}" />
| </h:outputLink>
|
I have written a ViewSelector class with a method that takes an instance of x and determines which view I want, I then return "object-view.seam" or something similar.
This does not work, so I wonder how I am supposed to do this.
Any suggestions that helps a newbie like me are much appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031846#4031846
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031846
19Â years
[JBoss Seam] - COMPOUNDs, ATOMs & MOLECULEs - don't try this at home!
by irVega
The prupose of this post is to save future, new SEAM users hours if not days.
Given what SEAM is and what it is capable of, the solution for someone with some relevant knowledge will probably take less time than it took to write this. In theory, a solution will take only a few minutes to develop, test and deploy.
I hope that a few of you will be able to quickly knock-up a full, working solution that meets the following very simple (but of a commonly occurring class of problem's) requirements ... or at least have a go so you can learn how to deal with the issues you may face.
Such an example, simple as it is, should help those wishing to evaluate SEAM.
See the schema below (all the sql runs in HSQLDB 1.8.0.1)
Create just 1 screen for creating records in MOLECULE with
1 - a drop-down list showing the ATOMs' PT_SYMBOLs
2 - a drop-down list showing the COMPOUNDs' NAMEs
3 - a text field for the QUANTITY
4 - a button to add the above values into the MOLECULE table
Please do not change the schema(below) and do not use JSPs if possible.
Provide a short note saying how long it took to design and develop your solution in SEAM and note where you had to make some tweaks to the OOTB behaviour of seam-gen or if you just hand-coded the whole lot.
Include all artefacts in your post - don't assume anything is obvious (especially to me).
Here's your schema:
| CREATE TABLE ATOM (
| ID_ BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY,
| PT_SYMBOL VARCHAR(3)
| )
|
| CREATE TABLE COMPOUND (
| ID_ BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY,
| NAME VARCHAR(10)
| )
|
| CREATE TABLE MOLECULE(
| ATOM_ID BIGINT,
| COMPOUND_ID BIGINT,
| QUANTITY INTEGER,
| PRIMARY KEY(ATOM_ID,COMPOUND_ID),
| CONSTRAINT VALID_ATOM FOREIGN KEY (ATOM_ID) REFERENCES ATOM(ID_),
| CONSTRAINT VALID_COMPOUND FOREIGN KEY (COMPOUND_ID) REFERENCES COMPOUND(ID_)
| )
|
You can also add the following data in case empty tables cause you grief (if so, please say why)...
| INSERT INTO ATOM (PT_SYMBOL) VALUES('H');
| INSERT INTO ATOM (PT_SYMBOL) VALUES('O');
| INSERT INTO COMPOUND (NAME) VALUES('Water');
| INSERT INTO MOLECULE (ATOM_ID,COMPOUND_ID,QUANTITY) VALUES(1,1,2);
| INSERT INTO MOLECULE (ATOM_ID,COMPOUND_ID,QUANTITY) VALUES(2,1,1);
| INSERT INTO COMPOUND (NAME) VALUES('CarbonDioxide');
| INSERT INTO ATOM (PT_SYMBOL) VALUES('C');
| INSERT INTO MOLECULE (ATOM_ID,COMPOUND_ID,QUANTITY) VALUES(3,2,1);
| INSERT INTO MOLECULE (ATOM_ID,COMPOUND_ID,QUANTITY) VALUES(2,2,2);
|
Finally, this should give some sensible output (a sanity-check) before you start coding:
| SELECT C.NAME, A.PT_SYMBOL,M.QUANTITY
| FROM ATOM A, COMPOUND C, MOLECULE M
| WHERE M.ATOM_ID = A.ID_
| AND M.COMPOUND_ID = C.ID_
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031845#4031845
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031845
19Â years