You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Brummeline Braaten <br...@gmail.com> on 2007/03/12 11:01:28 UTC

Update contens with commandlink

I have a <h:form> that shows the first 7 rows of a list. I would like to show
the entire list when a commandlink is clicked. How do I do that? 


Re: Update contens with commandlink IT WORKS!

Posted by Brummeline Braaten <br...@gmail.com>.
Now it works! Thanks for all your help! Now I have to find out how to change the
text on the outputtext to collaps when I show all the table items. This is quite
interesting:)



Re: Update contens with commandlink

Posted by Werner Punz <we...@gmail.com>.
Brummeline Braaten schrieb:
> Werner Punz <werner.punz <at> gmail.com> writes:
> 
>> commandlink value="All" action="tabnavigering.doloadentirelist" ...
>>
>> then you can trigger a list reload from your backend action, you however
>> have to savestate something so the state is kept. (either reload the
>> list every time you do something in your form, or keep the state somewhere)
>>
>>
> It sounds so difficult! I don't understand how to do this. I can send an action
> with a binding to my bean. And I can navigate from the bean through the
> navigationrules I've made in faces-config. But how can I tell the page to reload
> without the rows="7" attribute?
> 
Actually this is a basic jsf mechanism,
you do not need a navigation rule for this,

just use an action, once the action is triggered reload your entire list
and you are set.
It is more or less how you would make it in a rich client user interface
action->do something done...

The navigation rules are just there to allow a configuration based
navigation from one form to the other, as long as you stay in the same
form, just declare the action in your backing bean, and you are set.

This is one of the powers of jsf, that the programming model is very
close to a rich client user interface. Hoever if you come from a Struts
background, you have to unlearn some patterns struts does differently.


Too keep the i want to show the entire list setting you have to make
some web centric compromises.
The best bet in your case probably would be to keep the setting
of your list load in a hidden field, this is the closest you have to
normal html (there are other ways, like savestating the database model
or using savestate, either that or read up the savestate documentation
in the myfaces wiki)



So what you basically do is following
<h:inputHidden value="#{backendform.entirelistloaded}" />

or
<t:saveState value="#{backendform.entirelistloaded}" />


<h:commandLink action="#{backendform.doloadmyentirelist}" />

on the javaside:

List thedatalist = null;
boolean entirelistloaded = false;

private loadList() {
...
}

public String doloadmyentirelist() {
	loadList();
	entirelistloaded = true;
	return "done";
}



also for subsequent refreshes you might call loadList at a stage where
you need it (getter for instance or if you use shale, the init method)


like
public List getThedatalist() {
	if(thedatalist == null)
		loadList();
	return thedatalist;
}


An alternative way would be to use the shale View controller for this
initialisation or use the model savestating of the tomahawk data tables
or even the entire list via t:sae.

There are numerous ways to achieve what you want.


Re: Update contens with commandlink

Posted by Brummeline Braaten <br...@gmail.com>.
Werner Punz <werner.punz <at> gmail.com> writes:

> commandlink value="All" action="tabnavigering.doloadentirelist" ...
> 
> then you can trigger a list reload from your backend action, you however
> have to savestate something so the state is kept. (either reload the
> list every time you do something in your form, or keep the state somewhere)
> 
> 
It sounds so difficult! I don't understand how to do this. I can send an action
with a binding to my bean. And I can navigate from the bean through the
navigationrules I've made in faces-config. But how can I tell the page to reload
without the rows="7" attribute?





Re: Update contens with commandlink

Posted by Werner Punz <we...@gmail.com>.
Brummeline Braaten schrieb:
> Werner Punz <werner.punz <at> gmail.com> writes:
> 
>> first load the 7 items into a list
>> at the clicking of the command link load the entire list in the action...
>>
>>
> 
> So I need to lists? Now I have all the items in the same list. Here is my code:
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
> <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
> <html>
>  <f:view>
>   <head>
>    <meta http-equiv="content-type"content="text/html; charset=iso-8859-1">
>   </head>
>   <body>
>    <h:form id="metoder">
>    <f:verbatim>
>     <div id="category_list_heading">
>     Siste metodevarsler:
>     </div>
>    </f:verbatim>
>    <h:dataTable var="commissiontitles" value="#{tabnavigering.commissionList}" 
> rows="7">
>     <h:column>
>      <h:outputText style="category_list" styleClass="category" 
>  value="#{commissiontitles.oppdragsDato}"/>
>       <h:commandLink style="category_list" styleClass="category">
>        <h:outputText value="#{commissiontitles.metodeNavn}" />
>       </h:commandLink>
>      </h:column>
>     </h:dataTable>
>     <h:commandLink>
>      <h:outputText value="All >>"/>
>     </h:commandLink>
>    </h:form>
>   </body>
>  </f:view>
> </html>
> 
> When I click on <h:outputText value="All >>"/> I would like to see all of 
> the commissionList entries.
> 
> 
> 
commandlink value="All" action="tabnavigering.doloadentirelist" ...

then you can trigger a list reload from your backend action, you however
have to savestate something so the state is kept. (either reload the
list every time you do something in your form, or keep the state somewhere)


Re: Update contens with commandlink

Posted by Brummeline Braaten <br...@gmail.com>.
Werner Punz <werner.punz <at> gmail.com> writes:

> first load the 7 items into a list
> at the clicking of the command link load the entire list in the action...
> 
> 

So I need to lists? Now I have all the items in the same list. Here is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<html>
 <f:view>
  <head>
   <meta http-equiv="content-type"content="text/html; charset=iso-8859-1">
  </head>
  <body>
   <h:form id="metoder">
   <f:verbatim>
    <div id="category_list_heading">
    Siste metodevarsler:
    </div>
   </f:verbatim>
   <h:dataTable var="commissiontitles" value="#{tabnavigering.commissionList}" 
rows="7">
    <h:column>
     <h:outputText style="category_list" styleClass="category" 
 value="#{commissiontitles.oppdragsDato}"/>
      <h:commandLink style="category_list" styleClass="category">
       <h:outputText value="#{commissiontitles.metodeNavn}" />
      </h:commandLink>
     </h:column>
    </h:dataTable>
    <h:commandLink>
     <h:outputText value="All >>"/>
    </h:commandLink>
   </h:form>
  </body>
 </f:view>
</html>

When I click on <h:outputText value="All >>"/> I would like to see all of 
the commissionList entries.



Re: Update contens with commandlink

Posted by Werner Punz <we...@gmail.com>.
Brummeline Braaten schrieb:
> I have a <h:form> that shows the first 7 rows of a list. I would like to show
> the entire list when a commandlink is clicked. How do I do that? 
> 
> 
first load the 7 items into a list
at the clicking of the command link load the entire list in the action...