You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by arcelor <al...@gmail.com> on 2008/07/11 21:15:52 UTC
RE: [Trinidad] Inline Editable Table
I was trying the sample code below but I got following error:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Only one top level element is allowed in an XML document. Error processing
resource 'http://localhost:8080/Testing/faces/Ed...
<script type="text/javascript">var _AdfWindowOpenError='A popup window
blocker has been detected in your browser. Popu...
My set up is as follows:
trinidad verion 1.2.8
Tomacat 6
eclipse-jee-ganymede-win32
Any helpl will be appreciated
Thanks
Vijay
Mathias Walter wrote:
>
> Hi Eric,
>
> did you read my post regarding to inline editable table yesterday? I'm
> doing
> the same stuff. You have to declare <tr:resetActionListener/> inside the
> cancel button.
> Did you ever try to use a selectOneChoice component?
>
> --
> Kind regards,
> Mathias
>
> -----Original Message-----
> From: Justin mcKay [mailto:justinmckay@gmail.com]
> Sent: Wednesday, March 19, 2008 10:09 PM
> To: users@myfaces.apache.org
> Subject: [Trinidad] Inline Editable Table
>
>
>
> I am creating a simple inline editable table example but am having a
> little
> bit of trouble. So far I am able to create new rows, edit rows, and
> delete
> rows. The problem I am having is I would like to be able to cancel from
> an
> edit and if a user has entered some data that is overwritten from the
> existing entry. I will attach the code below but I was just trying to
> come
> up with a way of doing this where I don't have more than one copy of the
> list around, any help or suggestions would be greatly appreciated. There
> is
> only one bean, one jsf page, and the managed bean definition.
>
>
>
> Jsf page..
>
>
>
>
>
> <?xml version='1.0' encoding='windows-1252'?>
>
> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
>
> xmlns:f="http://java.sun.com/jsf/core"
>
> xmlns:tr="http://myfaces.apache.org/trinidad"
>
> xmlns:ui="http://java.sun.com/jsf/facelets">
>
> <f:view>
>
> <tr:form>
>
> <tr:table value="#{testPeople.people}" var="row"
> binding="#{testPeople.table}">
>
> <tr:column>
>
> <f:facet name="header">
>
> <tr:outputText value="First Name"/>
>
> </f:facet>
>
> <tr:inputText value="#{row.firstName}"
> readOnly="#{not testPeople.entryRow and not testPeople.editRow}"
> required="true"/>
>
> </tr:column>
>
> <tr:column>
>
> <f:facet name="header">
>
> <tr:outputText value="Last Name"/>
>
> </f:facet>
>
> <tr:inputText value="#{row.lastName}"
> readOnly="#{not testPeople.entryRow and not testPeople.editRow}"
> required="true"/>
>
> </tr:column>
>
> <tr:column>
>
> <f:facet name="header">
>
> <tr:outputText value="Age"/>
>
> </f:facet>
>
> <tr:inputText value="#{row.age}"
> readOnly="#{not testPeople.entryRow and not testPeople.editRow}"
> maximumLength="3">
>
> <f:validateLongRange minimum="1"
> maximum="125"/>
>
> </tr:inputText>
>
> </tr:column>
>
> <tr:column>
>
> <f:facet name="header">
>
> <tr:outputText value="Actions"/>
>
> </f:facet>
>
> <tr:panelHorizontalLayout>
>
> <f:facet name="separator">
>
> <tr:spacer
> width="2px"></tr:spacer>
>
> </f:facet>
>
> <tr:commandButton text="Add"
> action="#{testPeople.add}" rendered="#{testPeople.entryRow}"
> partialSubmit="true"/>
>
> <tr:commandButton text="Delete"
> action="#{testPeople.delete}" rendered="#{not testPeople.entryRow and not
> testPeople.editMode}" immediate="true" partialSubmit="true"/>
>
> <tr:commandButton text="Edit"
> action="#{testPeople.edit}" rendered="#{not testPeople.entryRow and not
> testPeople.editMode}" immediate="true" partialSubmit="true"/>
>
> <tr:commandButton text="Update"
> action="#{testPeople.update}" rendered="#{testPeople.editMode and
> testPeople.editRow}" partialSubmit="true"/>
>
> <tr:commandButton text="Cancel"
> action="#{testPeople.cancel}" rendered="#{testPeople.editMode and
> testPeople.editRow}" immediate="true" partialSubmit="true"/>
>
> </tr:panelHorizontalLayout>
>
> </tr:column>
>
> </tr:table>
>
> </tr:form>
>
> </f:view>
>
> </jsp:root>
>
>
>
>
>
> Java code..
>
>
>
> import java.util.ArrayList;
>
> import java.util.List;
>
>
>
> import org.apache.myfaces.trinidad.component.core.data.CoreTable;
>
> import org.apache.myfaces.trinidad.context.RequestContext;
>
>
>
>
>
>
>
> /**
>
> * Class: PersonFinder.java
>
> * Author:
>
> * Date: Mar 17, 2008
>
> * Version: 1.0
>
> * Description:
>
> */
>
> public class PersonFinder {
>
> private final String PEOPLE = "PEOPLE_LIST";
>
> private final String EDIT_ROW = "PERSON_EDIT_ROW";
>
> private CoreTable table;
>
>
>
> public PersonFinder(){
>
> if(getPeople() == null){
>
> List<Person> people = new ArrayList<Person>();
>
> people.add(new Person());
>
> setPeople(people);
>
> }
>
> }
>
>
>
> /**
>
> * @return the people
>
> */
>
> public List<Person> getPeople() {
>
> return
> (List<Person>)RequestContext.getCurrentInstance().getPageFlowScope().get(PEO
> PLE);
>
> }
>
> /**
>
> * @param people the people to set
>
> */
>
> public void setPeople(List<Person> people) {
>
>
> RequestContext.getCurrentInstance().getPageFlowScope().put(PEOPLE,
> people);
>
> }
>
>
>
> /**
>
> * @return the table
>
> */
>
> public CoreTable getTable() {
>
> return table;
>
> }
>
>
>
> /**
>
> * @param table the table to set
>
> */
>
> public void setTable(CoreTable table) {
>
> this.table = table;
>
> }
>
>
>
> /**
>
> * isEntryRow ie the bottom entry row
>
> * @return true if it is the entry row, false otherwise
>
> */
>
> public boolean isEntryRow(){
>
> Person row = (Person) getTable().getRowData();
>
> return row != null && row.getFirstName() == null;
>
> }
>
>
>
> /**
>
> * isEditRow ie the row the user wants to edit
>
> * @return true if it is the edit row, false otherwise
>
> */
>
> public boolean isEditRow(){
>
> boolean editRow = false;
>
> if(getEditRowNum() != null){
>
> editRow = getEditRowNum().intValue() ==
> getTable().getRowIndex();
>
> }
>
> return editRow;
>
> }
>
>
>
>
>
> /**
>
> * isEditMode ie the user clicked edit on a row
>
> * @return true if we are in editMode, false otherwise
>
> */
>
> public boolean isEditMode(){
>
> boolean editMode = false;
>
> if(getEditRowNum() != null){
>
> editMode = true;
>
> }
>
> return editMode;
>
>
>
> }
>
>
>
> /**
>
> * Helper to store the editRowNum in the PageScope
>
> * @param num
>
> */
>
> private void setEditRowNum(Integer num){
>
>
> RequestContext.getCurrentInstance().getPageFlowScope().put(EDIT_ROW, num);
>
> }
>
>
>
>
>
> /**
>
> * Helper to retrieve the editRowNum from the PageScope
>
> * @return
>
> */
>
> private Integer getEditRowNum(){
>
> return (Integer)
> RequestContext.getCurrentInstance().getPageFlowScope().get(EDIT_ROW);
>
> }
>
>
>
> //Actions
>
> public void add(){
>
> List<Person> people = getPeople();
>
> people.add(new Person());
>
>
>
> RequestContext.getCurrentInstance().addPartialTarget(table);
>
> }
>
>
>
> public void delete(){
>
> List<Person> people = getPeople();
>
> people.remove(table.getRowIndex());
>
> RequestContext.getCurrentInstance().addPartialTarget(table);
>
> }
>
>
>
> public void edit(){
>
> setEditRowNum(table.getRowIndex());
>
>
>
> //Delete the entry row
>
> List<Person> people = getPeople();
>
> if(people.size() > 0){
>
> people.remove(people.size()-1);
>
> }
>
>
>
> RequestContext.getCurrentInstance().addPartialTarget(table);
>
> }
>
>
>
> public void update(){
>
> List<Person> people = getPeople();
>
> people.add(new Person());
>
>
>
> setEditRowNum(null);
>
> RequestContext.getCurrentInstance().addPartialTarget(table);
>
> }
>
>
>
> public void cancel(){
>
> //How do I do it?
>
> }
>
>
>
> public class Person {
>
> private String firstName;
>
> private String lastName;
>
> private Integer age;
>
>
>
> /**
>
> * @return the firstName
>
> */
>
> public String getFirstName() {
>
> return firstName;
>
> }
>
> /**
>
> * @param firstName the firstName to set
>
> */
>
> public void setFirstName(String firstName) {
>
> this.firstName = firstName;
>
> }
>
> /**
>
> * @return the lastName
>
> */
>
> public String getLastName() {
>
> return lastName;
>
> }
>
> /**
>
> * @param lastName the lastName to set
>
> */
>
> public void setLastName(String lastName) {
>
> this.lastName = lastName;
>
> }
>
> /**
>
> * @return the age
>
> */
>
> public Integer getAge() {
>
> return age;
>
> }
>
> /**
>
> * @param age the age to set
>
> */
>
> public void setAge(Integer age) {
>
> this.age = age;
>
> }
>
> }
>
> }
>
>
>
>
>
> Faces config mapping...
>
>
>
>
>
> <managed-bean>
>
> <managed-bean-name>testPeople</managed-bean-name>
>
>
> <managed-bean-class>com.faces.bean.test.dynamicTable.PersonFinder</managed-b
> ean-class>
>
> <managed-bean-scope>request</managed-bean-scope>
>
> </managed-bean>
>
>
>
--
View this message in context: http://www.nabble.com/-Trinidad--Inline-Editable-Table-tp16165160p18410749.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
[Trinidad] Session timout and ViewExpiredException/PPR
Posted by Mathias Walter <ma...@gmx.net>.
Hi,
I've implemented an error page for the session timeout exception
(ViewExpiredException). If a session is timed out, the user will be
redirected to the login page.
Unfortunately, it does not work for PPR (just a simple tr:commandLink with
partialSubmit=true). How can I get it to work with PPR?
--
Regards,
Mathias