Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to access seam component that was created at the time the parameter value was set?
    text
    copied!<p>My url has a parameter name=SSA-COLUMB. The seam parameter (set in DevicesList.page.xml) is</p> <pre><code>&lt;param name="name" value="#{searchDeviceName.paramValue}"/&gt; </code></pre> <p>When I load the page the searchDeviceName component is instantiated and paramValue is set. I verified it with a print statement on setParamValue(). Here is the code for SearchDeviceName.java</p> <pre><code>@Name("searchDeviceName") @Scope(ScopeType.CONVERSATION) public class SearchDeviceName { public String paramValue; public Table table; public String sqlString; public ArrayList&lt;JoinClause&gt; joinList; public SearchDeviceName() { Table devTable = new Table("devices","d","dev_id"); setTable(devTable); setSqlString(" d.name like '%"+paramValue+"%'"); } &lt;getters and setters&gt; } </code></pre> <p>I have a stateless session bean that grabs an instance of this component to use in building a sql statement. But when I grab the component instance, it does not have paramValue set. Apparently it is a new instance of the component.</p> <pre><code>SearchDeviceName searchObj = (SearchDeviceName) Component.getInstance("searchDeviceName", ScopeType.CONVERSATION); </code></pre> <p>This is not the same instance of searchDeviceName that was instantiated when the parameter value got set. I know this because paramValue is null rather than set to "SSA-COLUMB".</p> <p>Is there any way to use in my session bean the same component intance that got created when the parameter value was set? How do I grab it?</p> <p>Here is the code that grabs the component</p> <pre><code>@Name("idListBuilder") public class IdListBuilder { @In private Context conversationContext; @In(create = true) EntityManager entityManager; private String sqlQuery; private Table headTable; private ArrayList&lt;String&gt; restrictionValues = new ArrayList&lt;String&gt;(); private ArrayList&lt;Table&gt; restrictionJoinTables = new ArrayList&lt;Table&gt;(); public IdListBuilder(Table table) { this.headTable = table; this.sqlQuery = "SELECT " + table.alias + "." + table.primaryKey + " FROM " + table.name + " " + table.alias; searchObjects.add("searchDeviceName"); searchObjects.add("searchOfficeState"); } public List&lt;Integer&gt; getIdList(){ evaluateSearchObjects(); createQuery(); /* Code for grabbing resultlist of query goes here. return resultList; */ return null; } public void evaluateSearchObjects() { SearchDeviceName searchObj = (SearchDeviceName) Component.getInstance("searchDeviceName", ScopeType.CONVERSATION); if ( searchObj != null ) { restrictionValues.add(searchObj.sqlString); restrictionJoinTables.add(searchObj.table); } } void createQuery(){ StringBuilder strBuilder = new StringBuilder(sqlQuery); strBuilder.append(" where "); for ( String str : restrictionValues ){ strBuilder.append(str); } System.out.println("done"); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload