-
1. Re: Question: Can static parameters be used in *.page.xml?
pmuir Jun 18, 2007 8:00 AM (in response to anescu)No you can't. Can you explain the use case?
-
2. Re: Question: Can static parameters be used in *.page.xml?
christian.bauer Jun 18, 2007 8:11 AM (in response to anescu)You can, using value="#{'foo'}" but please promise me you will not append the "name asc" to a database query!
-
3. Re: Question: Can static parameters be used in *.page.xml?
anescu Jun 18, 2007 8:11 AM (in response to anescu)Yes, here it is:
It is a Seam generated application, with some modifications, so we have
AbcList & AbcEdit for some of the entities.
It was required that the AbcList be ordered when you open the page by the first column.
So I have 3 way to open AbcList:
1) From the menu (s:link)
2) From the AbcEdit screen, by clicking the "back" button (also s:link)
3) From the AbcEdit screen, by clicking the "delete" button (which is a h:commandButton), this returns to the AbcList by using a navigation rule defined in AbcEdit.page.xml
In cases 1) & 2) I can add this:<f:param name="order" value="name asc"/>
And it works fine.
For 3) I tried to use the same but it is ignored. Then I placed the parameter in the AbcEdit.page.xml as in the first post, with the static value and it doesn't work. So I defined a Java bean with an attribute to keep the defeult order and now it works. But, as I said, it is so damn complicated to do.
Since there is no alternative I'll guess we'll stick with this solution. -
4. Re: Question: Can static parameters be used in *.page.xml?
anescu Jun 18, 2007 8:18 AM (in response to anescu)"christian.bauer@jboss.com" wrote:
You can, using value="#{'foo'}" but please promise me you will not append the "name asc" to a database query!
Hei, tnx
Well, I guess it is used in a hibernate query. It is used to order the list of objects by the first column. But this is what the generated pages do anyway, only that they do it only when you click on the column headers:<h:column> <f:facet name="header"> <s:link styleClass="columnHeader" value="Name #{abcList.order=='name asc' ? messages.down : ( abcList.order=='name desc' ? messages.up : '' )}"> <f:param name="order" value="#{abcList.order=='name asc' ? 'name desc' : 'name asc'}"/> </s:link> </f:facet> #{abc.name} </h:column>
We just need a default order when the page is loaded the first time. -
5. Re: Question: Can static parameters be used in *.page.xml?
pmuir Jun 18, 2007 8:24 AM (in response to anescu)The reason that you can't easily provide static parameters to pages.xml is that it is not normally a good design choice.
If you are using seam-gen/seam application framework then you would be much better off using an EntityQuery and components.xml to specify the default order. This also gets around the problem of ql injection christian discusses. -
6. Re: Question: Can static parameters be used in *.page.xml?
franciscoacb Jun 25, 2007 9:05 AM (in response to anescu)If you are installing your Query components by configuring them in components.xml then you can specify a default order like this (from docs):
<framework:entity-query name="people"
ejbql="select p from Person p"
order="lastName"
max-results="20"/>
but if you are using extension you can do this (there's no examples from docs about query objects usage by extension, but of course you can look at a Seam-Gen code generated):
public class PapelList extends EntityQuery {
...
@Override
public String getOrder() {
if ( super.getOrder() != null )
return super.getOrder();
else
return "sigla asc";
}
It worked for me, but since I'm very new to Seam (and to web dev at all) I'm not sure if it is the best solution for default order of if it's a "good code"