You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcio E Miranda <Ma...@fastsearch.com> on 2006/03/11 19:02:53 UTC

Beginner question about views and subviews in Struts Shale.

Hi,

 

I've a few questions regarding how Shale handles views and suvbviews:

 

1.	Why a redirect to somepage.faces (in the index.jsp for example)
will output a blank screen. I used to do that in my regular My Faces
application, but it doesn't seem to work with Shale.
2.	Do I have to create a managed bean for each jsp page? Before
Shale I didn't have to do that, JSF would build the view from the jsp
file. From what I've got so far from the samples, I have to register a
managed bean for each view in Shale. If I run a <jsp:forward
page="menu.faces"/>, without creating the managed bean I get an error
saying that it could not find the bean #{menu}
3.	I tried a simple clay configuration (shown below). The idea was
to encapsulate a composite component inside a subview. When Shale
execute the clay tag lib I get an error asking for a bean #{subview}.
This error got me confused, I thought the subview was a implementation
of the <f:subview>  component. What is happening here?

 

-          >>>>>Clay configuration:

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE view PUBLIC "-//Apache Software Foundation//DTD Shale Clay
View Configuration 1.0//EN"

 
"http://struts.apache.org/dtds/shale-clay-config_1_0.dtd">

<view>

 

 <component jsfid="baseOutput" extends="outputText" allowBody="false">

   <attributes>

       <set name="style" value="color:#99CC66"/>

       <set name="value" value="Test"/>

   </attributes>

 </component>

 

 <component allowBody="false" extends="subview" jsfid="searchFormPanel">

            <element renderId="2" jsfid="baseOutput"/>

 </component>

 

</view>

 

 

?>>>>>>>>>The jsp :

 

<%@ taglib
uri="http://struts.apache.org/shale/clay-plugin"prefix="clay"%>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

 

<f:view>

<html>

      <head>

            <title></title>

            <link rel="STYLESHEET" type="text/css" href="style.css">

      </head>

      <body>

            <clay:clay id="search" jsfid="searchFormPanel" />
<-- This line causes the error. If I use baseOutput instead, everything
goes fine.

      </body>     

</html>  

</f:view>

 

 

>>>>>>>>>>>>>>>>>Exception:

 

javax.servlet.ServletException: Cannot get value for expression
'#{subview}'
        javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
 
org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationF
ilter.java:285)

 

Root Cause:

 

javax.faces.FacesException: Cannot get value for expression '#{subview}'
 
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(S
ervletExternalContextImpl.java:421)
 
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspView
HandlerImpl.java:234)
 
org.apache.shale.clay.faces.ClayViewHandler.renderView(ClayViewHandler.j
ava:383)
 
org.apache.shale.faces.ShaleViewHandler.renderView(ShaleViewHandler.java
:143)
 
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352
)
        javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
 
org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationF
ilter.java:285)
 
 
Thanks in advance for the help.

 

 


Re: Beginner question about views and subviews in Struts Shale.

Posted by Craig McClanahan <cr...@apache.org>.
On 3/11/06, Marcio E Miranda <Ma...@fastsearch.com> wrote:
>
> Hi,
>
>
>
> I've a few questions regarding how Shale handles views and suvbviews:
>
>
>
> 1.      Why a redirect to somepage.faces (in the index.jsp for example)
> will output a blank screen. I used to do that in my regular My Faces
> application, but it doesn't seem to work with Shale.


There is no way to help diagnose this without seeing any exceptions that
were logged into the container's log file, and/or look at snippets of your
code.

2.      Do I have to create a managed bean for each jsp page? Before
> Shale I didn't have to do that, JSF would build the view from the jsp
> file. From what I've got so far from the samples, I have to register a
> managed bean for each view in Shale.


Shale imposes the same requirement that JSF does -- if you want JSF to
create the bean for you, it must be registered as a managed bean (typically
in request scope for a backing bean associated with a page).

If I run a <jsp:forward
> page="menu.faces"/>, without creating the managed bean I get an error
> saying that it could not find the bean #{menu}


This pattern works just fine in the Use Cases example (and the other Shale
examples) -- see the index.jsp page which does this:

    <jsp:forward page="usecases.faces"/>

to display the main menu.  So, there must be something else going on --
checking the server log for suspicious error messages is always a good place
to start.

3.      I tried a simple clay configuration (shown below). The idea was
> to encapsulate a composite component inside a subview. When Shale
> execute the clay tag lib I get an error asking for a bean #{subview}.
> This error got me confused, I thought the subview was a implementation
> of the <f:subview>  component. What is happening here?
>
>
>
> -          >>>>>Clay configuration:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE view PUBLIC "-//Apache Software Foundation//DTD Shale Clay
> View Configuration 1.0//EN"
>
>
> "http://struts.apache.org/dtds/shale-clay-config_1_0.dtd">
>
> <view>
>
>
>
> <component jsfid="baseOutput" extends="outputText" allowBody="false">
>
>    <attributes>
>
>        <set name="style" value="color:#99CC66"/>
>
>        <set name="value" value="Test"/>
>
>    </attributes>
>
> </component>
>
>
>
> <component allowBody="false" extends="subview" jsfid="searchFormPanel">
>
>             <element renderId="2" jsfid="baseOutput"/>
>
> </component>
>
>
>
> </view>
>
>
>
>
>
> ?>>>>>>>>>The jsp :
>
>
>
> <%@ taglib
> uri="http://struts.apache.org/shale/clay-plugin"prefix="clay"%>
>
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
>
>
>
> <f:view>
>
> <html>
>
>       <head>
>
>             <title></title>
>
>             <link rel="STYLESHEET" type="text/css" href="style.css">
>
>       </head>
>
>       <body>
>
>             <clay:clay id="search" jsfid="searchFormPanel" />
> <-- This line causes the error. If I use baseOutput instead, everything
> goes fine.
>
>       </body>
>
> </html>
>
> </f:view>
>
>
>
>
>
> >>>>>>>>>>>>>>>>>Exception:
>
>
>
> javax.servlet.ServletException: Cannot get value for expression
> '#{subview}'
>         javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
>
> org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationF
> ilter.java:285)
>
>
>
> Root Cause:
>
>
>
> javax.faces.FacesException: Cannot get value for expression '#{subview}'
>
> org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(S
> ervletExternalContextImpl.java:421)
>
> org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspView
> HandlerImpl.java:234)
>
> org.apache.shale.clay.faces.ClayViewHandler.renderView(ClayViewHandler.j
> ava:383)
>
> org.apache.shale.faces.ShaleViewHandler.renderView(ShaleViewHandler.java
> :143)
>
> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352
> )
>         javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
>
> org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationF
> ilter.java:285)
>
>
> Thanks in advance for the help.


Were you successful at running the existing sample apps, without making any
changes at all?  If those don't work, there might be something odd about the
configuration of your container.  Otherwise, the challenge is to figure out
what you are doing that is different from the examples that actually work.

Craig