I have a seam 2.2 app. Basically I have a form with about 30 input fields. Each field is backed by a property is SearchForm.java. When I click “Submit” I invoke DevicesList.java (implements EntityQuery) and jump to /DevicesList.xhtml. All the input fields and properties correspond to parameters listed DevicesList.page.xml.
In other words in DevicesList.page.xml we have
<param name="hostname" value="#{searchForm.devName}"/>
<param name="loopback" value="#{searchForm.devIp}"/>
<param name="platform" value="#{searchForm.platform}"/>
etc.
I am heavily customizing getEjbql() based on which searchForm properties are set. I have been stepping through the seam framework code and trying to find a datastructure to access that contains a list of parameters that have been set from the form. Where are these things?
If I have entered a string into the hostname field of the form, the hostname parameter must be set to the value of #{searchFrom.devName}. But how do I find out that the hostname parameter has been set?
The only alternative I can think of is to use reflection and loop through all the classes of SearchFrom and then perform introspection on the object to see which ones have been set and build my sql query from that.
There has to be a better way. Anyone know how this could be done?
This is done automagically by Seam, meaning that it won’t add a restriction for a field of the form that has no value, so if the user only inputs data on the, for example, devName and devIp fields, then the query will be something like:
select d from Device d where devName = ? and devIp = ?even if your DevicesQuery also adds 27 more restrictions for all the fields, they won’t be added to the query because they are empty