-
1. Re: Refreshing window using seam
gavin.king Apr 6, 2006 8:52 PM (in response to kittyk)I don't understand.
The page is re-rendered on the server *every* time an action is invoked....? -
2. Re: Refreshing window using seam
kittyk Apr 9, 2006 11:13 PM (in response to kittyk)Hi,
I'm not sure what the problem is, as when the delete action is performed the page automatically refreshes.
Basically, I have two data table's. For the list table, each column is an outputText value, and basically lists each record in the database. Each row is a record, each column is a field, for example, licence plate number.
For the "add" table, each column is an inputText value, and the final column is the add button.
Please see code below for an example...
Data Table One - List of records
<h:dataTable var="record" value="#{listOfRecords}" rendered="#{listOfRecords.rowCount>0}">
<h:column>
<f:facet name="header">
<h:outputText value="Record" />
</f:facet>
<h:commandLink value="#{record.lpn}" action="#{lpnWatchlistOperations.list}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Lpn" />
</f:facet>
<h:outputText value="#{record.lpn}" />
</h:column>
</h:dataTable>
Data Table Two - adding a record
<h:dataTable value="Add records">
<h:column>
<f:facet name="header">
<h:outputText value="Lpn" />
</f:facet>
<h:inputText value="#{lpnwatchlist.lpn}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Add Record?" />
</f:facet>
<h:commandButton value="add" action="#{add.add}" />
</h:column>
</h:dataTable>
So when the add button is pressed, it calls the add method which adds the record to the database. I'd then like to see it update my data table containing the list of records. However, this is not the case until i manually hit the refresh button on the page. Is there something I'm missing? -
3. Re: Refreshing window using seam
gavin.king Apr 9, 2006 11:33 PM (in response to kittyk)What scope is the DataModel?
-
4. Re: Refreshing window using seam
kittyk Apr 9, 2006 11:35 PM (in response to kittyk)It's an EVENT
-
5. Re: Refreshing window using seam
gavin.king Apr 9, 2006 11:56 PM (in response to kittyk)If that is really the case, then it will be rebuilt on every request to the server. Are you *sure* about that?
-
6. Re: Refreshing window using seam
kittyk Apr 10, 2006 12:07 AM (in response to kittyk)Hi Gavin,
Yeah I'm pretty sure.. Here's what I've got. I have 2 classes. 1 for add, the other for delete. Can you please check it out and let me know if you see anything wrong in relation to how I'm using Seam? Thanks heaps I really appreciate your help!
Class One - Delete
@Stateful
@Scope(EVENT)
@Name("lpnWatchlistOperations")
@Interceptors(SeamInterceptor.class)
public class FunctionsOfLpnWatchlistAction implements FunctionsOfLpnWatchlist {
@In
private Context sessionContext;
@DataModel
private List listOfRecords;
@DataModelSelection
@Out (required = false)
private LPNWatchlistItem lpnwatchlist;
private LPNWatchList list = PluginFactory.getPlugin(LPNWatchList.class);
/*
* (non-Javadoc)
*
* @see com.transtoll.ui.actions.FunctionsOfLpnWatchlist#list()
*/
@Factory ("listOfRecords")
public void list() {
listOfRecords = new ArrayList();
List recordList = list.getAllLpnWatchList();
for (LpnWatchListDto dto : recordList) {
LPNWatchlistItem item = new LPNWatchlistItem();
item.id = dto.id;
item.lpn = dto.lpn;
item.issuingRegion = dto.issuingRegion;
item.type = dto.type;
listOfRecords.add(item);
}
}
/* (non-Javadoc)
* @see com.transtoll.ui.actions.FunctionsOfLpnWatchlist#delete()
*/
public String delete() {
sessionContext.set("currentLpnWatchlistItem", lpnwatchlist);
listOfRecords.remove(lpnwatchlist);
LpnWatchListDto dto = createDto(lpnwatchlist);
list.deleteRecord(dto);
return "deleted";
}
}
Class Two - Add
@Stateless
@Name("add")
@Interceptors(SeamInterceptor.class)
public class AddAction implements Add {
@In (required = false)
private LPNWatchlistItem lpnwatchlist;
@In
private Context sessionContext;
@In
private FacesContext facesContext; //used for outputting error messages.
private LPNWatchList list = PluginFactory.getPlugin(LPNWatchList.class);
/* (non-Javadoc)
* @see com.transtoll.ui.actions.Add#add()
*/
@IfInvalid(outcome=Outcome.REDISPLAY)
public String add() {
LpnWatchListDto dto = createDto(new LPNWatchlistItem(lpnwatchlist.getId(), lpnwatchlist.getLpn(), lpnwatchlist.getIssuingRegion(), lpnwatchlist.getType()));
list.add(dto);
return "added";
}
/* (non-Javadoc)
* @see com.transtoll.ui.actions.Add#update()
*/
@IfInvalid(outcome=Outcome.REDISPLAY)
public String update() {
sessionContext.set("currentLpnWatchlistItem", lpnwatchlist);
LpnWatchListDto dto = createDto(lpnwatchlist);
list.update(dto);
return "updated";
} -
7. Re: Refreshing window using seam
gavin.king Apr 10, 2006 12:13 AM (in response to kittyk)Yep, that looks OK.
Try using the debugger and the Seam debug page to find out what is going on. -
8. Re: Refreshing window using seam
kittyk Apr 10, 2006 1:06 AM (in response to kittyk)Okay will do, thanks! :)