I am developing an android app, which contains a Navigation Drawer Activity. This in turn contains two tabs "Alabanzas" and "Tema", both are accessed from the side menu.
The "Alabanzas" tab is a Fragment that contains a custom ArrayAdapter that contains a ListView.
In the ActionBar place a SearchView element for the searches within the ListView of "Alabanzas", however I can not link the search with the elements of the ListView
My Classes are the Following ...
Class MainActivity with Navigation Drawer
Error in the method onQueryTextChange of the method onCreateOptionsMenu generates the miadaptador.getFilter().Filter(s); because that adapter is different from the one installed in the Adapter class that has the search method
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.MenuInflater;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.SearchView;
import com.example.misael.corolldm.Fragmentos.Alabanza;
import com.example.misael.corolldm.Fragmentos.Temas;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
CargarFragmento(new Alabanza());
navigationView.getMenu().getItem(0).setChecked(true);
}
#Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_search,menu);
MenuItem item = menu.findItem(R.id.menuSearch);
SearchView searchView= (SearchView)item.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
#Override
public boolean onQueryTextSubmit(String s) {
return false;
}
#Override
public boolean onQueryTextChange(String s) {
// miadaptador.getFilter().filter(s);
return false;
}
});
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
return super.onOptionsItemSelected(item);
}
#SuppressWarnings("StatementWithEmptyBody")
#Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_camera) {
CargarFragmento(new Alabanza());
} else if (id == R.id.nav_gallery) {
CargarFragmento(new Temas());
} else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) {
} else if (id == R.id.nav_send) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
private void CargarFragmento(Fragment fragmento){
FragmentManager Manager = getSupportFragmentManager();
Manager.beginTransaction().replace(R.id.contenedorFragmento, fragmento).commit();
}
}
Xml Archive activity_main
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Class Adaptador
public class Adaptador extends BaseAdapter implements Filterable {
Context contexto;
ArrayList<Datos> ListaObjetos;
ArrayList<Datos> mStringFilterList;
ValueFilter valueFilter;
public Adaptador(Context contexto, ArrayList<Datos> listaObjetos) {
this.contexto = contexto;
this.ListaObjetos = listaObjetos;
mStringFilterList=listaObjetos;
}
/*
Retorna cantidad de elementos de la vista
*/
#Override
public int getCount() {
return this.ListaObjetos.size();
}
/*
Retorna objeto puntual de la posicion que indico
*/
#Override
public Object getItem(int i) {
return this.ListaObjetos.get(i);
}
/*
Retorna Id del objeto puntual de la posicion que indico
*/
#Override
public long getItemId(int i) {
return this.ListaObjetos.get(i).getId();
}
/*
Se ejecuta en cada secuencia de cada hito de la listview
*/
#Override
public View getView(int i, View view, ViewGroup viewGroup) {
View vista = view;
//Inyectamos el layout definido dentro de la vista del ListView
LayoutInflater inflate = LayoutInflater.from(contexto);
vista = inflate.inflate(R.layout.itemlistview, null);
//Referenciamos el titulo
TextView titulo = (TextView) vista.findViewById(R.id.tw_titulo);
titulo.setText(ListaObjetos.get(i).getTitulo().toString());
return vista;
}
#Override
public Filter getFilter() {
if (valueFilter == null) {
valueFilter = new ValueFilter();
}
return valueFilter;
}
private class ValueFilter extends Filter {
#Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
if (constraint != null && constraint.length() > 0) {
ArrayList<Datos> filterList = new ArrayList<Datos>();
for (int i = 0; i < mStringFilterList.size(); i++) {
if ((mStringFilterList.get(i).getTitulo().toUpperCase())
.contains(constraint.toString().toUpperCase())) {
Datos data = new Datos(mStringFilterList.get(i)
.getId(), mStringFilterList.get(i)
.getTitulo());
filterList.add(data);
}
}
results.count = filterList.size();
results.values = filterList;
} else {
results.count = mStringFilterList.size();
results.values = mStringFilterList;
}
return results;
}
#Override
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
ListaObjetos = (ArrayList<Datos>) filterResults.values;
notifyDataSetChanged();
}
}
}
Class Alabanza
public class Alabanza extends Fragment {
ListView listaDatos;
ArrayList<Datos> Lista= new ArrayList<>();
Adaptador miadaptador;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_alabanza, container, false);
listaDatos = (ListView)view.findViewById(R.id.lstDatos);
Lista.add(new Datos(1,"A la Diestra de Dios"));
Lista.add(new Datos(2,"A solas al Huerto"));
Lista.add(new Datos(3,"A ti Señor"));
Lista.add(new Datos(4,"A veces me pregunto"));
Lista.add(new Datos(5,"Al divino Salvador"));
Lista.add(new Datos(6,"Al Mundo Paz"));
Lista.add(new Datos(7,"Alabado el gran manantial"));
Lista.add(new Datos(8,"Alabanzas a Dios dad"));
Lista.add(new Datos(9,"Aleluya Amen"));
Lista.add(new Datos(10,"Aleluya oh Creador"));
Lista.add(new Datos(11,"Angeles cantando estan"));
Lista.add(new Datos(12,"Apocalipsis 14_6"));
Lista.add(new Datos(13,"Bendito Amor"));
Lista.add(new Datos(14,"Blancos Vestidos"));
Lista.add(new Datos(15,"Cantad a Jehova"));
Lista.add(new Datos(16,"Canten a Cristo Rey"));
Lista.add(new Datos(17,"Cerca de ti señor"));
Lista.add(new Datos(18,"Contigo estoy tan Feliz"));
Lista.add(new Datos(19,"Cuan Amables son tus Moradas"));
Lista.add(new Datos(20,"Cuando el Señor manifesto"));
Lista.add(new Datos(21,"Cuarenta Años de amor"));
Lista.add(new Datos(22,"Del Celeste Pais"));
Lista.add(new Datos(23,"Don Inefable"));
Lista.add(new Datos(24,"Dulce Oracion"));
Lista.add(new Datos(25,"El Amigo del Angel"));
Lista.add(new Datos(26,"El Apóstol de la Consolación"));
Lista.add(new Datos(27,"El Evangelio de Cristo"));
Lista.add(new Datos(28,"El Lema de la Iglesia"));
Lista.add(new Datos(29,"El Manto de la Eleccion"));
Lista.add(new Datos(30,"El mas bello amor"));
Lista.add(new Datos(31,"El Nuevo Israel"));
Lista.add(new Datos(32,"El Replicar del Campanal"));
Lista.add(new Datos(33,"El Resplandor de tu nacimiento"));
Lista.add(new Datos(33,"El vino a mi corazon"));
Lista.add(new Datos(34,"Elección de Dios"));
Lista.add(new Datos(35,"En la Judea"));
Lista.add(new Datos(36,"En las mañanas de bendicion"));
Lista.add(new Datos(37,"Engrandecido sea Dios"));
Lista.add(new Datos(38,"Eres el Angel"));
Lista.add(new Datos(39,"Estoy resuelto"));
miadaptador = new Adaptador(getActivity().getApplicationContext(),Lista);
listaDatos.setAdapter(miadaptador);
//Agregamos escuchador
listaDatos.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Datos obj=(Datos) adapterView.getItemAtPosition(i);
//Creamos el paso hacia la nueva activity
Intent paso=new Intent(getActivity().getApplicationContext(), DetalleActivity.class);
paso.putExtra("objeto", (Serializable) obj); // Serializamos el traspaso del objeto
//Realiza el traspaso a la otra activity
startActivity(paso);
}
});
return view;
}
}
Xml Archive menu_search
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/menuSearch"
android:title="Search"
android:icon="#android:drawable/ic_menu_search"
app:actionViewClass="android.widget.SearchView"
app:showAsAction="always"></item>
</menu>
If anyone could help me perform searches in the listView of the fragment "Alabanzas", any idea will be very well received
Thank you
I have a little problem with my authentication application, I want to add the user's cookies only when he check the box "remember me", I work with JSF and Managedbean to do this .. the problem is that even if I check the box it returns me a false and does not change the status of the checkbox in true and does not reach the condition where I put inside my instantiation of the Cookie, below my source code and thank you.
Form :
<h:form class="login" id="formuLogin">
<h:inputText id="loginChasseur" placeholder="Username" value="#{chasseur_loginBean.login_chasseur}" required="true" requiredMessage="#{msg['login.loginChasseur']}"></h:inputText>
<h:message style="color:white;" id="loginChasseurMessage" for="loginChasseur" errorClass="erreur" />
<h:inputSecret id="mdpChasseur" placeholder="Password" value="#{chasseur_loginBean.password_chasseur}" required="true" requiredMessage="#{msg['login.mdpChasseur']}"></h:inputSecret>
<h:message style="color:white;" id="mdpChasseurMessage" for="mdpChasseur" errorClass="erreur" />
<h:messages globalOnly="true" infoClass="info" />
<h:commandButton action="#{chasseur_loginBean.validateUsernamePassword}" value="Connexion" class="btn btn-success btn-sm"></h:commandButton>
<div class="remember-forgot">
<div class="row">
<div class="col-md-6">
<div class="checkbox">
<label>
<h:selectBooleanCheckbox value="{chasseur_loginBean.remembre}"/> Se souvenir de moi
</label>
</div>
</div>
<div class="col-md-6 forgot-pass-content">
Mot de passe oublié?
</div>
</div>
</div>
</h:form>
My managed bean :
#ManagedBean(name="chasseur_loginBean")
#SessionScoped
public class Chasseur_loginBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private Logger log = Logger.getLogger(PrelevementBean.class);
private String login_chasseur;
private String password_chasseur;
private String statut_chasseur;
private boolean remembre = false;
private ChasseurLoginServices chasseurService = new ChasseurLoginServicesImpl();
#PostConstruct
public void initBean() {
log.info("postconstruct chasseurLogin");
System.out.println("la valeur de la checkbox post constract : "+remembre);<br>
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
Cookie[] cookies = request.getCookies();
if(cookies!=null) {
for (Cookie cookie : cookies) {
if(cookie.getName().equals("loginChassCookie")) {
login_chasseur = cookie.getValue();
}
}
}
}
//validate login
public String validateUsernamePassword() {
boolean valid = chasseurService.checkuser(login_chasseur, password_chasseur);
if (valid) {
System.out.println("la valeur de la checkbox 1 : "+remembre);
if(this.remembre) {
System.out.println("la valeur de la checkbox 2 : "+remembre);
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
Cookie cookie = new Cookie("loginChassCookie", login_chasseur);
cookie.setMaxAge(60 * 60 * 24 * 30);
response.addCookie(cookie);
}
System.out.println("la valeur de la checkbox 3 : "+remembre);
HttpSession session = SessionUtils.getSession();
session.setAttribute("loginChasseur", login_chasseur);
return "chasseurCorrect";
} else {
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_WARN,
"Identifiant ou mot de passe incorrect",
""));
return "login";
}
}
public String getLogin_chasseur() {
return login_chasseur;
}
public void setLogin_chasseur(String login_chasseur) {
this.login_chasseur = login_chasseur;
}
public String getPassword_chasseur() {
return password_chasseur;
}
public void setPassword_chasseur(String password_chasseur) {
this.password_chasseur = password_chasseur;
}
public String getStatut_chasseur() {
return statut_chasseur;
}
public void setStatut_chasseur(String statut_chasseur) {
this.statut_chasseur = statut_chasseur;
}
public boolean isRemembre() {
return remembre;
}
public void setRemembre(boolean remembre) {
this.remembre = remembre;
}
}
I'm getting the error:
com.sun.faces.mgbean.ManagedBeanCreationException: No se puede crear el bean administrado loginBean.
Se han encontrado los problemas siguientes:- No se encuentra el bean o la clase de propiedad com.pf.mbean.loginBean para el bean administrado loginBean.
In english it would be something like:
Cannot create management bean loginBean there are found following troubles: Cannot find bean or property class com.pf.mbean.loginBean for the managment bean loginBean
My bean is the following:
package com.pf.mbean;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.http.HttpSession;
import org.primefaces.context.RequestContext;
#ManagedBean(name="loginBean")
public class loginBean implements Serializable
{
private static final long serialVersionUID = -2152389656664659476L;
private String nombre;
private String clave;
private boolean logeado = false;
public boolean estaLogeado()
{
return logeado;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getClave() {
return clave;
}
public void setClave(String clave) {
this.clave = clave;
}
public boolean isLogeado() {
return logeado;
}
public void setLogeado(boolean logeado) {
this.logeado = logeado;
}
public void login(ActionEvent actionEvent)
{
RequestContext context = RequestContext.getCurrentInstance();
FacesMessage msg = null;
if (nombre != null && nombre.equals("admin") && clave != null && clave.equals("admin"))
{
logeado = true;
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido: ", nombre);
}
else
{
logeado = false;
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error","Credenciales no válidas");
}
FacesContext.getCurrentInstance().addMessage(null, msg);
context.addCallbackParam("estaLogeado", logeado);
if (logeado)
context.addCallbackParam("view", "gauge.xhtml");
}
public void logout()
{
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
session.invalidate();
logeado = false;
}
}
And my faces-config.xml I have set the following configuration:
<managed-bean>
<managed-bean-name>loginBean</managed-bean-name>
<managed-bean-class>com.pf.mbean.loginBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope> </managed-bean>
In my login.xhtml I'm refer to the bean at this way:
<p:inputText value="#{loginBean.nombre}" id="username"
required="true" label="username" />
<h:outputLabel for="password" value="Clave:" />
<p:password value="#{loginBean.clave}" id="password" required="true"
label="password" />
But I have no idea why the class has not been found, any idea?
I´m trying to implement a richfaces autocomplete component, the problem i have is that the autocompleteMethod is never called.
<rich:autocomplete id="formacode" styleClass="champ_select310" layout="list"
autocompleteList="#{enregistrementFormationsMBean.toShow}"
autocompleteMethod="#{enregistrementFormationsMBean.autocomplete}"
value="#{enregistrementFormationsMBean.formacode}">
</rich:autocomplete>
the MBean:
public String getFormacode() {
return testDto.getFormacode();
}
public void setFormacode(String formacode) {
testDto.setFormacode(formacode);
}
public List<String> getToShow() {
return testDto.getToShow();
}
public void setToShow(List<String> toShow) {
testDto.setToShow(toShow);
}
public List<String> autocomplete(String prefix) {
Map<String, String> map;
List<String> listOfItems = new ArrayList<String>();
try {
map = testFacade.getFormacode(prefix);
for (Entry<String, String> e : map.entrySet()) {
listOfItems.add(e.getValue());
}
} catch (RemoteException | ServiceException e1) {
e1.printStackTrace();
}
setToShow(listOfItems);
return listOfItems;
}
When i debug, the getter getToShow and the function autocomplete are never called.
I am using richfaces 4.3.3
ps: in the log
ERROR [com.liferay.faces.bridge.application.MissingResourceImpl] (http--127.0.0.1-8080-3) Resource handler=[com.liferay.faces.bridge.application.ResourceHandlerOuterImpl#73ceed1] was unable to create a resource for resourceName=[AutocompleteBase.js] libraryName=[org.richfaces.images] contentType=[null]
WARNING [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-5) JSF1064 : Impossible de localiser ou de servir une ressource, Autocomplete.js, depuis la bibliothèque org.richfaces.images
thank's for your help !!
When I download a file, the filename that is display in the "save as" dialog window its the name of the view (Page2.pdf) and not the filename "cyn.pdf".
Header content disposition is on line 161 of FileUploadController and "download" its call on line 34 of Page2.xhtml
FileUploadController Bean
#ManagedBean(name = "fileUploadController")
#SessionScoped
public class FileUploadController implements Serializable {
private static final long serialVersionUID = 1L;
//tama�o del buffer
private static final int DEFAULT_BUFFER_SIZE = 10240;
private byte[] archi = new byte[0];
public String nombre;
public String ruta;
public String nombreArchivo;
public byte[] getArchi() {
return archi;
}
public void setArchi(byte[] archi) {
this.archi = archi;
}
// Nombre del Archivo
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getRuta() {
return ruta;
}
public void setRuta(String ruta) {
this.ruta = ruta;
}
// ruta fisica del archivo
public String getRealPath() {
FacesContext aFacesContext = FacesContext.getCurrentInstance();
ServletContext context = (ServletContext) aFacesContext.getExternalContext().getContext();
return context.getRealPath("/");
}
/* subida del archivo con sus atributos */
public void fileUpload(FileUploadEvent event, String nombre, String type, String directorio) {
try {
this.nombre = "cyn" + type;
this.ruta = directorio + getNombre();
this.archi = getFileContents(event.getFile().getInputstream());
File file = new File(directorio);
nombreArchivo = file.getName();
// Crea el directorio, incluidos subdirectorios q no existan
if (!file.exists()) {
file.mkdirs();
}
} catch (Exception ex) {
System.out.println("Error en la subida " + ex);
}
}
private byte[] getFileContents(InputStream in) {
byte[] bytes = null;
try {
// write the inputStream to a FileOutputStream
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int read = 0;
bytes = new byte[1024];
while ((read = in.read(bytes)) != -1) {
bos.write(bytes, 0, read);
}
bytes = bos.toByteArray();
in.close();
in = null;
bos.flush();
bos.close();
bos = null;
} catch (IOException e) {
System.out.println(e.getMessage());
}
return bytes;
}
// Guardar el archivo
public void guardar() {
try {
FileOutputStream out;
out = new FileOutputStream(ruta);
System.out.print("out" + out);
out.write(archi);
System.out.print(archi);
out.close();
} catch (Exception ex) {
System.out.println(ex);
}
}
/*-------------------- Servlet Descarga Archivos----------------------------------------------*/
public void downLoad() throws IOException, ServletException {
FacesContext contexto = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) contexto.getExternalContext().getResponse();
//ruta de los archivos
System.out.println("paso parametro ruta " + ruta);
File file = new File(ruta);
System.out.println("paso parametro ruta a file " + file);
/*Validacion*/
if (!file.exists()) {
System.out.println("El archivo no existe!");
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
response.reset();
response.setBufferSize(DEFAULT_BUFFER_SIZE);
response.setContentType("application/pdf");
response.setHeader("Content-Length", String.valueOf(file.length()));
/*Ventana de abrir/guardar*/
/*attachment: muestra la ventana*/
response.setHeader("Content-Disposition", "attachment; Nombre del Archivo=\"" + nombreArchivo + "\"");
System.out.println("NOmbre archivo en download" + nombreArchivo);
//inicializo el input y el output
BufferedInputStream input = null;
BufferedOutputStream output = null;
try {
input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int length;
while ((length = input.read(buffer)) > 0) {
output.write(buffer, 0, length);
}
} finally {
//cierro
input.close();
output.close();
}
contexto.responseComplete();
}
}
View: Page2.xhtml
<h:body>
<h2>Acceso Alumno</h2>
<h1>Alumnos registrados </h1>
<h:form>
<h:dataTable id ="tabla" value ="#{alumno.getListaAlumno()}" var= "var" border="1">
<h:column>
<f:facet name="header">Id </f:facet>
<h:outputText value = "#{var.id}"/>
</h:column>
<h:column>
<f:facet name="header">Nombre y Apellidos </f:facet>
<h:outputText value = "#{var.nombreApellidos}"/>
</h:column>
<h:column>
<f:facet name="header">Matricula </f:facet>
<h:outputText value = "#{var.matricula}"/>
</h:column>
<h:column>
<f:facet name="header">ProductBox </f:facet>
<h:commandButton action="#{fileUploadController.downLoad}" value="Guardar Archivo" >
<f:setPropertyActionListener target="#{fileUploadController.ruta}" value="#{var.pdf}" />
</h:commandButton>
</h:column>
</h:dataTable>
</h:form>
<h:form>
<h:commandButton action="home?faces-redirect=true" value="Home" />
</h:form>
<!-- Cerrar Sesion -->
Cerrar Sesion
</h:body>
</html>
Try using the following Content-disposition
response.setHeader("Content-disposition", "attachment;filename=cyn.pdf");