MultiPage navigation problem

UI Components for JSF
Post Reply
Viwritis
Posts: 2
Joined: 29 Aug 2014, 09:10

20 Apr 2015, 14:15

Hello

The problem occurs only on mobile devices, when testing on my pc in eclipse everything is working just fine.
Only on mobile devices there is no reaction when Im clicking navigation button.
The problem is with "Wyniki" button i the header of first page.

My .xhtml

Code: Select all

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pm="http://primefaces.org/mobile">

<f:view renderKitId="PRIMEFACES_MOBILE" />

<h:head>

</h:head>

<h:body>

	<pm:page id="first">
		<pm:header title="Wyszukiwanie">
			<h:form>
				<p:commandButton styleClass="ui-btn-right ui-btn-inline" value="Wyniki"
					icon="ui-icon-gear"	action="#{odczytyView.wyniki}" />
			</h:form>
		</pm:header>

		<pm:content>
			<h:form id="main">
				<pm:field>
					<p:outputLabel for="dataOd" value="Data od: " />
					<p:calendar required="true" id="dataOd"
						value="#{odczytyView.dataOd}" pattern="dd-MM-yyyy"
						requiredMessage="Musisz podac przynajmniej date od kiedy chcesz przegladac odczyty!" />
				</pm:field>
				<pm:field>
					<p:outputLabel for="datado" value="Data do: " />
					<p:calendar id="datado" value="#{odczytyView.dataDo}"
						pattern="dd-MM-yyyy" />
				</pm:field>
				<pm:field>
					<p:outputLabel for="typ" value="Typ odczytu: "
						style="margin-top: 5px;" />
					<p:selectOneMenu id="typ" value="#{odczytyView.typ}"
						style="margin-top: 5px;">
						<f:selectItem itemLabel="Wybierz jeden " itemValue="" />
						<f:selectItem itemLabel="Odczyt kwadransowy" itemValue="f_k" />
						<f:selectItem itemLabel="Odczyt godzinowy" itemValue="f_g" />
						<f:selectItem itemLabel="Odczyt dobowy" itemValue="f_d" />
						<f:selectItem itemLabel="Odczyt miesieczny" itemValue="f_m" />
					</p:selectOneMenu>
				</pm:field>
				<pm:field>
					<p:outputLabel for="id_licznika" value="ID licznika: " />
					<p:inputText id="id_licznika" value="#{odczytyView.id_licznika}"
						onkeypress="if(event.which < 48 || event.which > 57) return false;" />
				</pm:field>
				<p:commandButton id="wyszukaj2" value="Wyszukaj"
					actionListener="#{odczytyView.wyszukaj}" update=":second:tabela"
					action="pm:second?transition=turn" />
			</h:form>
		</pm:content>
	</pm:page>

	<pm:page id="second">
		<pm:header title="Wyniki">
			<p:button outcome="pm:first?transition=turn" value="Powrot " />
		</pm:header>

		<pm:content>
			<p:dataTable id="tabela" var="odczyt" reflow="true"
				value="#{odczytyView.wyszukane}" paginator="true" rows="10"
				tableStyleClass="ui-table-columntoggle">

				<p:column headerText="ID odczytu: " sortBy="#{odczyt.id_odczytu}">
					<h:outputText value="#{odczyt.id_odczytu}" />
				</p:column>

				<p:column headerText="Data odczytu: "
					sortBy="#{odczyt.data_odczytu}">
					<h:outputText value="#{odczyt.data_odczytu}">
						<f:convertDateTime type="date" pattern="dd-MM-yyyy HH:mm" />
					</h:outputText>
				</p:column>

				<p:column headerText="Stan odczytu: "
					sortBy="#{odczyt.stan_odczytu}">
					<h:outputText value="#{odczyt.stan_odczytu}" />
				</p:column>

				<p:column headerText="ID licznika: " sortBy="#{odczyt.id_licznika}">
					<h:outputText value="#{odczyt.id_licznika}" />
				</p:column>

				<p:column headerText="Zuzycie kwadransowe: "
					sortBy="#{odczyt.zu_k_0}">
					<h:outputText value="#{odczyt.zu_k_0}" />
				</p:column>

				<p:column headerText="Zuzycie godzinowe: " sortBy="#{odczyt.zu_g_0}">
					<h:outputText value="#{odczyt.zu_g_0}" />
				</p:column>

				<p:column headerText="Zuzycie dobowe: " sortBy="#{odczyt.zu_d_0}">
					<h:outputText value="#{odczyt.zu_d_0}" />
				</p:column>

				<p:column headerText="Zuzycie miesieczne: "
					sortBy="#{odczyt.zu_m_0}">
					<h:outputText value="#{odczyt.zu_m_0}" />
				</p:column>
			</p:dataTable>

		</pm:content>
	</pm:page>

</h:body>

</html>


my faces-config.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">
<application>
   <navigation-handler>
      org.primefaces.mobile.application.MobileNavigationHandler
   </navigation-handler>
</application>
	<application>
     <el-resolver>
         org.primefaces.application.exceptionhandler.PrimeExceptionHandlerELResolver
    </el-resolver>
</application>
<factory>
    <exception-handler-factory>
       org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory
    </exception-handler-factory>
</factory>
</faces-config>
and my bean

Code: Select all

@ManagedBean(name="odczytyView")
@ApplicationScoped
public class OdczytyView implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Date dataOd;
	private Date dataDo;
	private int id_licznika;
	private String typ;
	private List<Odczyt> wyszukane;
	private List<Odczyt> filtrowanaTabela;
	
	private Date dzis;
	private List<Boolean> list;
	
	@PostConstruct
	public void init(){
		wyszukane=new ArrayList<Odczyt>();
		Calendar cal=Calendar.getInstance();
		dzis=cal.getTime();
		list = Arrays.asList(true, true, true, true, true, true, true, true);
	}
	public void onToggle(ToggleEvent e) {
        list.set((Integer) e.getData(), e.getVisibility() == Visibility.VISIBLE);
        System.out.println(list);
    }
	public void wyszukaj(){
		if(dataOd==null && dataDo==null && id_licznika==0 && typ==null){
			for (Map.Entry<String,String> entry : FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().entrySet()) {
				  String key = entry.getKey();
				  String value = entry.getValue();
				  System.out.println("KEY: "+key+"  <-->  VALUE: "+value);
				}
			String oD=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("first:main:dataOd_input");
			String dO=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("first:main:datado_input");
			String idL=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("first:main:id_licznika_input");
			String typO=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("first:main:typ");
			DateFormat format = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
			try {
				dataOd = format.parse(oD);
				dataDo = format.parse(dO);
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			id_licznika = Integer.parseInt(idL);
			typ = typO;
		}
		System.out.println(dataOd);
		System.out.println(dataDo);
		System.out.println(id_licznika);
		System.out.println(typ);
		if(dataOd!=null && dataDo!=null && (typ!=null && !typ.isEmpty()) && id_licznika>0){
			DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
			System.out.println("****Invoking the Odczyty Service****1");
			Client client = ClientBuilder.newClient();
			WebTarget target = client.target(getBaseURI());		
			Invocation pogodaInvocation = target.path("rest").path("odczyty").path(df.format(dataOd)+","+df.format(dataDo)+","+typ+","+id_licznika).request().buildGet();
			Response response = pogodaInvocation.invoke();
			Odczyty odczyty = response.readEntity(Odczyty.class);
			wyszukane=odczyty.odczyty;
			response.close(); 
		}else if(dataOd!=null && dataDo!=null && (typ!=null && !typ.isEmpty()) && id_licznika==0){
			DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
			System.out.println("****Invoking the Odczyty Service****2"+typ);
			Client client = ClientBuilder.newClient();
			WebTarget target = client.target(getBaseURI());	
			System.out.println(dataDo);
			Invocation pogodaInvocation = target.path("rest").path("odczyty").path(df.format(dataOd)+","+df.format(dataDo)+","+typ).request().buildGet();
			Response response = pogodaInvocation.invoke();
			Odczyty odczyty = response.readEntity(Odczyty.class);
			wyszukane=odczyty.odczyty;
			response.close(); 
		}else if(dataOd!=null && dataDo==null && (typ!=null && !typ.isEmpty()) && id_licznika==0){
			DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
			System.out.println("****Invoking the Odczyty Service****3");
			Client client = ClientBuilder.newClient();
			WebTarget target = client.target(getBaseURI());		
			Invocation pogodaInvocation = target.path("rest").path("odczyty").path(df.format(dataOd)+","+typ).request().buildGet();
			Response response = pogodaInvocation.invoke();
			Odczyty odczyty = response.readEntity(Odczyty.class);
			wyszukane=odczyty.odczyty;
			response.close(); 
		}else if(dataOd!=null && dataDo==null && (typ==null || typ.isEmpty()) && id_licznika>0){
			DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
			System.out.println("****Invoking the Odczyty Service****4");
			Client client = ClientBuilder.newClient();
			WebTarget target = client.target(getBaseURI());		
			Invocation pogodaInvocation = target.path("rest").path("odczyty").path("dataLicznik").path((df.format(dataOd))+","+id_licznika).request().buildGet();
			Response response = pogodaInvocation.invoke();
			Odczyty odczyty = response.readEntity(Odczyty.class);
			wyszukane=odczyty.odczyty;
			response.close(); 
		}else if(dataOd!=null && dataDo!=null && (typ==null || typ.isEmpty()) && id_licznika==0){
			DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
			System.out.println("****Invoking the Odczyty Service****5");
			Client client = ClientBuilder.newClient();
			WebTarget target = client.target(getBaseURI());		
			Invocation pogodaInvocation = target.path("rest").path("odczyty").path("data2").path((df.format(dataOd))+","+df.format(dataDo)).request().buildGet();
			Response response = pogodaInvocation.invoke();
			Odczyty odczyty = response.readEntity(Odczyty.class);
			wyszukane=odczyty.odczyty;
			response.close(); 
		}else if(dataOd!=null && dataDo==null && (typ==null || typ.isEmpty()) && id_licznika==0){
			DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
			System.out.println("****Invoking the Odczyty Service****6");
			Client client = ClientBuilder.newClient();
			WebTarget target = client.target(getBaseURI());		
			Invocation pogodaInvocation = target.path("rest").path("odczyty").path("data1").path(df.format(dataOd)).request().buildGet();
			Response response = pogodaInvocation.invoke();
			Odczyty odczyty = response.readEntity(Odczyty.class);
			wyszukane=odczyty.odczyty;
			response.close(); 
		}
		dataOd=null;
		dataDo=null;
		id_licznika=0;
		typ=null;
	}
	public String wyniki(){
		System.out.println("wyniki");
		return "pm:second?transition=turn";
	}
	private static URI getBaseURI() {
		return UriBuilder.fromUri("http://localhost:8080/com.soulless.odczyty").build();
	}
	public Date getDataOd() {
		return dataOd;
	}
	public void setDataOd(Date dataOd) {
		this.dataOd = dataOd;
	}
	public Date getDataDo() {
		return dataDo;
	}
	public void setDataDo(Date dataDo) {
		this.dataDo = dataDo;
	}
	public int getId_licznika() {
		return id_licznika;
	}
	public void setId_licznika(int id_licznika) {
		this.id_licznika = id_licznika;
	}
	public List<Odczyt> getWyszukane() {
		return wyszukane;
	}
	public void setWyszukane(List<Odczyt> wyszukane) {
		this.wyszukane = wyszukane;
	}
	public String getTyp() {
		return typ;
	}
	public void setTyp(String typ) {
		this.typ = typ;
	}
	public List<Odczyt> getFiltrowanaTabela() {
		return filtrowanaTabela;
	}
	public void setFiltrowanaTabela(List<Odczyt> filtrowanaTabela) {
		this.filtrowanaTabela = filtrowanaTabela;
	}
	public Date getDzis() {
		return dzis;
	}
	public void setDzis(Date dzis) {
		this.dzis = dzis;
	}

	public List<Boolean> getList() {
		return list;
	}

	public void setList(List<Boolean> list) {
		this.list = list;
	}
}
Please help. Any comment can help ;)
PrimeFaces version:primefaces-5.0.jar
JSF implementation name/version:JSF 2.2
Server name/version :Tomcat v7.0

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests